(Translate GOOGLE)
Hello I want to install a weather station with a DHT22 probe and I have a UNO card and a SIM900 card. My goal is to transfer the statements to my site in Json. Only I can not understand the connection of the SIM900 to the UNO and I did not find a script *.uno to direct my data to my site. Can you help a novice.
Thank you,
Laure
You did not find any examples of how to do the simm thingy? Hummm.
SIM900 GSM GPRS Shield with Arduino | Random Nerd Tutorials
Try to follow the RNT tutoriual to get the simi-thing working.
That you only give the most basic of requirements you might look into using POST and GET for taking to your web site.
Using words like "arduino post data to server" can get results like Write POST Data to Server with Arduino Uno with WiFi – Eli the Computer Guy and How to post JSON data to a HTTP server endpoint from your ESP32 development board with ArduinoJson - Techcoil Blog
Yea, there is no prewritten script to do what you want you'll have to figure it out yourself.
Me, I have 13 ESP32's sending data to and receiving data from my website via a Raspberry Pi.
Google translate)
Thank you Idahowalker for this information.
My problem is the connection between the SIM900 card, the UNO card and the DHT22 probe. I can't figure out where to connect them.
Laure
Maybe something is getting lost in translation. Does UNO card = Arduino UNO board and SIM900 card = SIM900 shield?
The 2 should just plug together.
You need to find a schematic for the SIM900 shield so you can work out which pins are not being used by the SIM900. You should then be able to connect the DHT22 to one of the unused pins.
Did you get the simmy thing working as per the tutorial?
I have these models:
https://www.amazon.fr/Arduino-A000066-Mémoire-flash-32/dp/B008GRTSV6/ref=sr_1_5?__mk_fr_FR=ÅMÅŽÕ %C3%91&crid=38VBQAU03AGQ3&keywords=arduino+uno&qid=1649173779&sprefix=arduino+uno%2Caps%2C92&sr=8-5
https://www.amazon.fr/Module-transmission-données-Arduino-Cellular/dp/B0796S7V9C/ref=sr_1_10?__mk_fr_FR=ÅMÅŽÕ %C3%91&crid=3FQ2F9LRM3H9X&keywords=sim900&qid=1649173831&sprefix=sim900%2Caps%2C127&sr=8-10
My problem I don't know where to connect my DHT22 sensor to my UNO card.
Thank you
Laure
have a look at How-to-use-DHT-22-sensor-Arduino-Tutorial
initially test the DHT-22 without the SIM900 in place - make sure it works
plug the SIM900 into the UNO and see if the DHT-22 still woks
then start testing the SIM900
Idahowalker I followed your links the connection is made and the DHT22 probe works on the UNO.
I can't get the SIM900 to work on the UNO.
Laure
Cool you got one part working. Me, I've not used a simmy thingy, so no help from me in getting it going. perhaps searching for a tutorial that matches the simmy card you got may be helpful?
I tried without the SIM900 and it works on the UNO alone.
With the card I can't get it to work (mySerial(7, 8) and pin 6 on the UNO
Laure
You understand I cannot see your code, right?
You understand I cannot see your wiring, right?
You understand you can post your code in code tags so others can see your code?
You understand you can post images of your project so others can see try to see the wiring, right?
The code that works
/*
______ _ _///_ _ _ _
/ _ \ (_) | ___| | | | (_)
| [_| |__ ___ ___ _ ___ _ __ | |__ | | ___ ___| |_ _ __ ___ _ __ _ ___ _ _ ___
| ___/ _ \| __|| __| |/ _ \| '_ \_____| __|| |/ _ \/ _| _| '__/ \| '_ \| |/ \| | | |/ _ \
| | | ( ) |__ ||__ | | ( ) | | | |____| |__ | | __/| (_| |_| | | (_) | | | | | (_) | |_| | __/
\__| \__,_|___||___|_|\___/|_| [_| \____/|_|\___|\____\__\_| \___/|_| |_|_|\__ |\__,_|\___|
| |
\_|
Fichier : DHT22surTraceurSerie.ino
Description : Programme permettant de tracer graphiquement, sur le traceur série de l'IDE Arduino, l'évolution de
la température et taux d'humidité, mesurés par notre DHT22, branché sur la pin D6 de notre Arduino Uno
Auteur : Jérôme TOMSKI (https://passionelectronique.fr/)
Créé le : 06.06.2021
Librairie utilisée : DHT sensor library (https://github.com/adafruit/DHT-sensor-library)
*/
#include <DHT.h>
#define brocheDeBranchementDHT 6 // La ligne de données de notre DHT22 sera branchée sur la pin D6 de notre Arduino
#define typeDeDHT DHT22 // Spécification du type de DHT utilisé (ici, ce sera un DHT22, comme indiqué)
// Instanciation de la librairie DHT
DHT dht(brocheDeBranchementDHT, typeDeDHT);
// ========================
// Initialisation programme
// ========================
void setup () {
// Initialisation de la liaison série (pour retourner les infos au traceur série de l'ordi)
Serial.begin(9600);
// Initialisation du DHT22;
dht.begin();
// Transmission de valeurs à 0 au traceur série, pour avoir un graphique partant de 0 sur l'axe vertical
Serial.println("0,0");
delay(2000);
}
// =================
// Boucle principale
// =================
void loop () {
// Lecture des données
float tauxHumidite = dht.readHumidity(); // Lecture du taux d'humidité (en %)
float temperatureEnCelsius = dht.readTemperature(); // Lecture de la température, exprimée en degrés Celsius
// Vérification des données
if (isnan(tauxHumidite) || isnan(temperatureEnCelsius)) {
delay(2000);
return; // Si aucune valeur n'a été reçue par l'Arduino, on attend 2 secondes, puis on redémarre la fonction loop()
}
// Transmission des valeurs
Serial.print(tauxHumidite);
Serial.print(",");
Serial.print(temperatureEnCelsius);
Serial.println();
// Temporisation de 2 secondes, avant nouvelle mesure (pour respect des directives du fabricant)
delay(2000);
}
The code I want
Is it compatible? I can't find or put the "pin6" code.
/*
Arduino-Sim900_Internet
By Guannan Wang 2015-10-25
Basic sketch for GPRS shield sim900
This code is based on the work done by
Mateo Velez - Metavix - for Ubidots Inc. (2014-08-20), as well as
Jeffery Sadler https://github.com/jsadler2/stormwater/blob/master/raingage.ino
This is a basic example to post a value on Ubidots with a simple
function "save_value".
You'll need:
* An Arduino Uno
* A GPRS shield Sim900
This example code is in the public domain.
*/
//--------------------------------------------------------------
//------------------------------Libraries-----------------------
//--------------------------------------------------------------
#include <SoftwareSerial.h>
#include <String.h>
#include "DHT.h"
#define NOT_AN_INTERRUPT -1
SoftwareSerial mySerial(7, 8); //your pins to serial communication, for some Sim900 board, they are (2,3)
int valor;
// for DHTTYPE
#define DHTTYPE DHT22 // DHT 22 (AM2302)
int sensorPin = A0;
int reading;
const int rainGauge =3;
volatile int rainCount = 0;
float rainCorrect;
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(sensorPin, DHTTYPE);
//-------------------------------------------------------------
//---------------------Ubidots Configuration-------------------
//-------------------------------------------------------------
String token = "FsgQDF7vkDBA750zxhe8QCPJHuAlkYxjLGNi47sBiMzaQzsIHr020qtADKjC"; //your token to post value
String idvariableT = "562d523c762542758a2b8382"; //ID of your temperature
String idvariableH = "562d61ed7625422d332ce386"; //ID of your humidity
String idvariableR = "563195ed7625423a9e51b0eb"; //ID of your rain fall
void setup()
{
mySerial.begin(19200); //the GPRS baud rate
Serial.begin(19200); //the serial communication baud rate
analogReference(DEFAULT);
attachInterrupt(digitalPinToInterrupt(rainGauge),rainGageClick,RISING); // Digital Pins with Interrupts
// https://www.arduino.cc/en/Reference/AttachInterrupt
Serial.println(rainGauge);
delay(10000);
}
void loop()
{
int value = analogRead(A0);
//
int sensorReadingT = readDHTSensorT();
int sensorReadingH = readDHTSensorH();
Serial.println("sensorReadingT");
Serial.println(sensorReadingT);
Serial.println("sensorReadingH");
Serial.println(sensorReadingH);
// rain gauge
rainCorrect= rainCount/100.0;
Serial.println(rainCorrect);
//read pin A0 from your arduino
save_value(String(sensorReadingT),idvariableT); //call the save_value function
save_value(String(sensorReadingH),idvariableH);
save_value(String(rainCorrect),idvariableR);
if (mySerial.available())
Serial.write(mySerial.read());
}
//this function is to send the sensor data to Ubidots, you should see the new value in Ubidots after executing this function
void save_value(String value, String idvariable)
{
int num;
String le;
String var;
var="{\"value\":"+ value + "}";
num=var.length();
le=String(num);
for(int i = 0;i<3;i++)
{
mySerial.println("AT+CGATT?"); //this is made repeatedly because it is unstable
delay(2000);
ShowSerialData();
}
mySerial.println("AT+CSTT=\"CMNET\",\"\",\"\""); //replace with your providers' APN
delay(1000);
ShowSerialData();
mySerial.println("AT+CIICR"); //bring up wireless connection
delay(3000);
ShowSerialData();
mySerial.println("AT+CIFSR"); //get local IP adress
delay(2000);
ShowSerialData();
mySerial.println("AT+CIPSPRT=0");
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSTART=\"tcp\",\"things.ubidots.com\",\"80\""); //start up the connection
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSEND"); //begin send data to remote server
delay(3000);
ShowSerialData();
mySerial.print("POST /api/v1.6/variables/"+idvariable);
delay(100);
ShowSerialData();
mySerial.println("/values HTTP/1.1");
delay(100);
ShowSerialData();
mySerial.println("Content-Type: application/json");
delay(100);
ShowSerialData();
mySerial.println("Content-Length: "+le);
delay(100);
ShowSerialData();
mySerial.print("X-Auth-Token: ");
delay(100);
ShowSerialData();
mySerial.println(token);
delay(100);
ShowSerialData();
mySerial.println("Host: things.ubidots.com");
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println(var);
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println((char)26);
delay(7000);
mySerial.println();
ShowSerialData();
mySerial.println("AT+CIPCLOSE"); //close the communication
delay(1000);
ShowSerialData();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
void rainGageClick(){
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 200ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 200)
{
rainCount++;
}
last_interrupt_time = interrupt_time;
}
// get data from the DHT22
int readDHTSensorT(){
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float h = dht.readHumidity();
int t = dht.readTemperature();
// print out the voltage
Serial.print("Humidity:");
Serial.println(h); //to degrees ((voltage - 500mV) times 100)
Serial.print("Temperature:");
Serial.print(t);
Serial.println(" degree(C)");
return t;
Serial.println(t);
}
// get data (humidity) from the DHT22
int readDHTSensorH(){
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float h = dht.readHumidity();
int t = dht.readTemperature();
// print out the voltage
Serial.print("Humidity:");
Serial.println(h);
Serial.print("Temperature:");
Serial.print(t);
Serial.println(" degree(C)");
return h;
Serial.println(h);
}
If sensorPin was changed from A0 to a 6 then
DHT dht(sensorPin, DHTTYPE);
would be changed to use sensor pin 6.
Welcome to the forum.
Once you got your system up and running you may want to look into a better sensor. The DHT22 are not very good in today's world. Have a look at the BME280 for instance.
Hello,
I changed the old code to this:
// for DHTTYPE
#define DHTTYPE DHT22 // DHT 22 (AM2302)
int sensorPin = 6;
int reading;
const int rainGauge =3;
volatile int rainCount = 0;
float rainCorrect;
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(sensorPin, DHTTYPE)
Unfortunately it doesn't work.
Here is the result.
Despite my many attempts to branch, this code does not work.
I'm coming back to you to find out if you have similar code that works.
Thank you.
Laure
/*
Arduino-Sim900_Internet
By Guannan Wang 2015-10-25
Basic sketch for GPRS shield sim900
This code is based on the work done by
Mateo Velez - Metavix - for Ubidots Inc. (2014-08-20), as well as
Jeffery Sadler https://github.com/jsadler2/stormwater/blob/master/raingage.ino
This is a basic example to post a value on Ubidots with a simple
function "save_value".
You'll need:
* An Arduino Uno
* A GPRS shield Sim900
This example code is in the public domain.
*/
//--------------------------------------------------------------
//------------------------------Libraries-----------------------
//--------------------------------------------------------------
#include <SoftwareSerial.h>
#include <String.h>
#include "DHT.h"
#define NOT_AN_INTERRUPT -1
SoftwareSerial mySerial(7, 8); //your pins to serial communication, for some Sim900 board, they are (2,3)
int valor;
// for DHTTYPE
#define DHTTYPE DHT22 // DHT 22 (AM2302)
int sensorPin = A0;
int reading;
const int rainGauge =3;
volatile int rainCount = 0;
float rainCorrect;
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(sensorPin, DHTTYPE);
//-------------------------------------------------------------
//---------------------Ubidots Configuration-------------------
//-------------------------------------------------------------
String token = "FsgQDF7vkDBA750zxhe8QCPJHuAlkYxjLGNi47sBiMzaQzsIHr020qtADKjC"; //your token to post value
String idvariableT = "562d523c762542758a2b8382"; //ID of your temperature
String idvariableH = "562d61ed7625422d332ce386"; //ID of your humidity
String idvariableR = "563195ed7625423a9e51b0eb"; //ID of your rain fall
void setup()
{
mySerial.begin(19200); //the GPRS baud rate
Serial.begin(19200); //the serial communication baud rate
analogReference(DEFAULT);
attachInterrupt(digitalPinToInterrupt(rainGauge),rainGageClick,RISING); // Digital Pins with Interrupts
// https://www.arduino.cc/en/Reference/AttachInterrupt
Serial.println(rainGauge);
delay(10000);
}
void loop()
{
int value = analogRead(A0);
//
int sensorReadingT = readDHTSensorT();
int sensorReadingH = readDHTSensorH();
Serial.println("sensorReadingT");
Serial.println(sensorReadingT);
Serial.println("sensorReadingH");
Serial.println(sensorReadingH);
// rain gauge
rainCorrect= rainCount/100.0;
Serial.println(rainCorrect);
//read pin A0 from your arduino
save_value(String(sensorReadingT),idvariableT); //call the save_value function
save_value(String(sensorReadingH),idvariableH);
save_value(String(rainCorrect),idvariableR);
if (mySerial.available())
Serial.write(mySerial.read());
}
//this function is to send the sensor data to Ubidots, you should see the new value in Ubidots after executing this function
void save_value(String value, String idvariable)
{
int num;
String le;
String var;
var="{\"value\":"+ value + "}";
num=var.length();
le=String(num);
for(int i = 0;i<3;i++)
{
mySerial.println("AT+CGATT?"); //this is made repeatedly because it is unstable
delay(2000);
ShowSerialData();
}
mySerial.println("AT+CSTT=\"CMNET\",\"\",\"\""); //replace with your providers' APN
delay(1000);
ShowSerialData();
mySerial.println("AT+CIICR"); //bring up wireless connection
delay(3000);
ShowSerialData();
mySerial.println("AT+CIFSR"); //get local IP adress
delay(2000);
ShowSerialData();
mySerial.println("AT+CIPSPRT=0");
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSTART=\"tcp\",\"things.ubidots.com\",\"80\""); //start up the connection
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSEND"); //begin send data to remote server
delay(3000);
ShowSerialData();
mySerial.print("POST /api/v1.6/variables/"+idvariable);
delay(100);
ShowSerialData();
mySerial.println("/values HTTP/1.1");
delay(100);
ShowSerialData();
mySerial.println("Content-Type: application/json");
delay(100);
ShowSerialData();
mySerial.println("Content-Length: "+le);
delay(100);
ShowSerialData();
mySerial.print("X-Auth-Token: ");
delay(100);
ShowSerialData();
mySerial.println(token);
delay(100);
ShowSerialData();
mySerial.println("Host: things.ubidots.com");
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println(var);
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println((char)26);
delay(7000);
mySerial.println();
ShowSerialData();
mySerial.println("AT+CIPCLOSE"); //close the communication
delay(1000);
ShowSerialData();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
void rainGageClick(){
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 200ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 200)
{
rainCount++;
}
last_interrupt_time = interrupt_time;
}
// get data from the DHT22
int readDHTSensorT(){
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float h = dht.readHumidity();
int t = dht.readTemperature();
// print out the voltage
Serial.print("Humidity:");
Serial.println(h); //to degrees ((voltage - 500mV) times 100)
Serial.print("Temperature:");
Serial.print(t);
Serial.println(" degree(C)");
return t;
Serial.println(t);
}
// get data (humidity) from the DHT22
int readDHTSensorH(){
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float h = dht.readHumidity();
int t = dht.readTemperature();
// print out the voltage
Serial.print("Humidity:");
Serial.println(h);
Serial.print("Temperature:");
Serial.print(t);
Serial.println(" degree(C)");
return h;
Serial.println(h);
}
The DHT one wire thingy does not use analog.
Look at the example code of how to read the DHT. THE DHT22 is NOT an ANALOG read. Go back and look at the code you posted in post#12 that works for the DHT 22 and compare it to your code..
Does this
look like this
?
What happens if you did
int reading = dht.readTemperature();
and put the DHT on pin 6 and change
to int sensorPin = 6;
I don't understand anything, it's not so easy to be up to speed in Arduino codes, especially when you don't know anything about this code area.
Personally I thought it was simpler and I was wrong because I thought there were ready-made codes for my project.
I drop my project and I thank the people who helped me with a lot of patience.
Laure
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.