How to get data through IoT ? If the sensor gives only analogous output/input data

How to get data through IoT ? If the sensor gives only analogous output/input data
I need to visualize the data through IoT means thingsspeak or other channel.

/*
int analogPin = A3;
int Rawval ; // variable to store the value read
int Scaleval ;
int RELAY_pin = 10; // Relay is connected to pin D10
void setup()
{
Serial.begin(9600); // setup serial
pinMode(RELAY_pin, OUTPUT);
}

void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
// For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);

/// === RELAY code ===
// raw value 675 correspond to 20%, so for 5% we will get 169
if ( Rawval < 169) digitalWrite(RELAY_pin, HIGH);
else digitalWrite(RELAY_pin, LOW);
}
*/

Tried.Please modify the code for data visualization

If you want to do it on your own, try this. There are many examples and tutorials for what you want to do. randomnerdtutorials.com usually has decent ones. Give it a good effort and then come back if you are stuck.

If you want to pay someone to do it for you, try this.

1 Like

Those things tried with long back . Please help.
I am using only arduino uno & that sensor gives only Analogous output/inout

:frowning_face:

To participate in the IOT world and get analog sensor data from your T to the I, you need to buy a device that can connect to the I.

as @DaveEvans states you require a device which connects to the internet to upload data and display it
I have used LoraWAN (the Things Lora UNO), WiFi (ESP32) and 4G modems to connect various micros to the IoT
I tend tend to use the MyDevices/cayenne desktiop for results display as it is easy use and free for a small number of devices, e.g. river data showing water temperature, height, etc

try a web search for arduino to cayenne and you will get plently of links with suggestions for devices, sample code, etc

I need to visualize analogous output or input from an analogous sensor

(Edited your quote because it doesn't matter if the sensor outputs ANALOG (not analogous) or DIGITAL data.)

No problem. Connect a TFT or OLED screen to your UNO and visualize to your heart's content! No internet connection required.

That won't help with your original goal...

...but at least you'd get good visuals.

all the plots displayed in the graphs of post #7 were from analogue sensors
this is an example of a simple test using an ESP8266 connected to a local WiFi network uploading some temperature analogue test data over MQTT to the cayenne desktop

2 Likes

Please provide the link of examples

do a web search for the IoT topic you are interested in, e.g. arduino cayenne will give plenty of links showing how to send analogue sensor data, etc to cayenne desktop
you will require a board with IoT capability - you could add this to the UNO but it is probably simpler to use an ESP32 or ESP8266 and port your sensor code to it then add the IoT functionality

Can you modified the code?

Same for ESP8266

this code runs on an ESP8266 NodeMCU using MQTT to send data from a BME280 sensor to the cayenne desktop

// ESP8266 and BME280 uploading data to MyDevice/cayenne 

/*
This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. If you have not already installed the ESP8266 Board Package install it using the instructions here: https://github.com/esp8266/Arduino#installing-with-boards-manager.
2. Select your ESP8266 board from the Tools menu.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

// BME280 sensor

// ESP8266 nodeMCU v3 GPIO5 D1 SCL GPIO4 D2 SDA
// ESP32 devkit GPIO22 SCL GPIO21 SDA

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "horace2017";
char wifiPassword[] = "CindyMittens413194";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "8e92cd80-8267-11eb-8779-7d56e82df461";
char password[] = "7df991c57a5cdd0c696d55186bb2a5607756ace0";
char clientID[] = "46192110-865b-11eb-883c-638d8ce4c23d";


void setup() {
	Serial.begin(115200);
  Serial.println();
  Serial.println(F("BME280 test upload to cayenne desktop"));
    // default settings (you can also pass in a Wire library object like &Wire2)
  bool status = bme.begin(0x76);  
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
	Cayenne.loop();
 delay(5000);
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
  float temp=22.0, pressure, altitude, humidity;
   Serial.print("Temperature = ");
  Serial.print(temp=bme.readTemperature());
  Serial.println(" *C");
	// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
	Cayenne.virtualWrite(0, millis());
	// temperature is channel 1
	Cayenne.celsiusWrite(1, temp);
  Serial.print("Pressure = ");
  Serial.print(pressure=bme.readPressure() / 100.0F);
  Serial.println(" hPa");
  Cayenne.virtualWrite(2, pressure);
  
  Serial.print("Approx. Altitude = ");
  Serial.print(altitude=bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");
  Cayenne.virtualWrite(3, altitude);
 
  Serial.print("Humidity = ");
  Serial.print(humidity=bme.readHumidity());
  Serial.println(" %");
  Cayenne.virtualWrite(4, humidity);
 
  Serial.println();
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
	//CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

which displays

at 9.20 you can see the effect when I put my finger on the sensor

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.