Introduction: Arduino Wifi Temperature Logger
This is a simple demo using the ESP8266 and Cactus Micro (a arduino compatible board) to update a remote server (https://data.sparkfun.com/) using a digital temperature sensor.
Step 1: Materials
The Cactus Micro is an arduino compatible dev board, it integrated a WIFI chip ESP8266.
- 1 x Cactus Micro - contains a ESP8266 module ESP-11 (https://www.tindie.com/products/AprilBrother/cactus-micro-arduino-compatible-plus-wifi-esp8266/)
1 x DS18B20 Digital Temperature Sensor
1 x 4.7k resistor
1 x Power supply (4.3V up to 12V, I used a 3.7v)
Step 2: Connecting the Wires Together
- Connect esp8266 module is easy. Just plug in to the pins.
- DS18B20 - DQ(2) -> Cactus pin 14, DQ(2) -> 4.7KR -> VCC(3.3V)
Step 3: Arduino Setup and Sketch
The sketch code: https://github.com/AprilBrother/cactus-micro/blob/...
For Cactus Micro Rev2, the default firmware for esp8266 is espduino. Please use this sketch instead. https://github.com/AprilBrother/cactus-micro-r2/tree/master/libraries/CactusMicro/examples/temperatureLogger
Step 4: SparkFun Setup
We create a data stream at SparkFun, follow this link to do this. https://data.sparkfun.com/streams/make
Once you've created your stream, keep the window open so you have easy access to your public and private keys handy - you'll need those to replace the KEY in the Arduino sketch.
Now you are ready to start sending data.
49 Comments
5 years ago
hi,
could you update the code for cactus micro rev2 please?
trying, but i can not.
question: how long data keeps on sparkfun? (the free one)
Reply 5 years ago
Hi, We've updated the sketch for Cactus Micro Rev2 today. It should work with default esp8266 espduino firmware.
https://github.com/AprilBrother/cactus-micro-r2/tree/master/libraries/CactusMicro/examples/temperatureLogger
Reply 5 years ago
Can you make it reading temperature from several sensors? Should it be like example below or there is better way? Thanks.
tempSenNum++;
if (tempSenNum > 3){
tempSenNum = 1;
}
switch (tempSenNum) {
case 1:
DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #1
break;
case 2:
DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #2
break;
case 3:
DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #3
break;
}
6 years ago
My order from Tindie arrived... ready to build... but link for code not there...
https://github.com/AprilBrother/cactus-micro/blob/master/examples/arduino/temperatureLogger/temperatureLogger.ino
Reply 6 years ago
Hi,
I have just updated the link for the sketch.
Please note: the code is only work on rev1. You must change the code to hardware serial port Serial1.
7 years ago on Introduction
Hi there,
I'm interested in using this Cactus micro in my project for sending data to a website.
Do the flash memory,ram and ROM stack when I use it with Arduino Uno? Or any different in term of speed?
Thank you
Reply 7 years ago on Introduction
You should compare it with Arduino Leonardo or Arduino Micro. The micro controller is ATMega32U4.
7 years ago on Introduction
it's coming along yanc, look how cool the cactus micro look inside the plant pot..
https://www.instructables.com/id/the-plant-pot/step...
Reply 7 years ago on Introduction
It looks great! I
7 years ago on Introduction
I made some change with your code. Not tested. I replace some "Serial" with the SoftwareSerial port "debug". Please diff the code.
https://gist.github.com/volca/da178cd000abb91d649f
Reply 7 years ago on Introduction
i copied your code above and using IDE 1.0.6 now - still no online upload, also the temperature is really high all the time, very strange.
.
still never AT+CWMODE=1 or AT+CWJAP lines shown on the serial monitor;
temperature1021
light256
water53
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPCLOSE
temperature1022
light252
water33
AT+CIPSTART="TCP","184.106.153.149",80
AT+CIPCLOSE
.
i still think it is the code, rgb led works with the right colors and sensors are picking up data as well. just no online connection
Reply 7 years ago on Introduction
For test WIFI connection, please make it simple. Run the sketch below.
https://gist.github.com/volca/69c559cfb50e5580668c
Reply 7 years ago on Introduction
Module Test: OK
AT+CWJAP="8d59bb","244221619"
....................Can not connect to the WiFi.
Module Test: OK
AT+CWJAP="8d59bb","244221619"
....................Can not connect to the WiFi.
Module Test: OK
AT+CWJAP="8d59bb","244221619"
....................Can not connect to the WiFi.
Module Test: OK
AT+CWJAP="8d59bb","244221619"
....
keeps repeating this. isn't it supposed to first set the mode, AT+CWMODE=1 ? this line doesn't showup on the software serial monitor..
Reply 7 years ago on Introduction
I edited the line 31:
Original:
delay(500);//delay after mode change
Edited:
delay(3000);//delay after mode change
Give it enough time. It will connect the WIFI easy. I just tested the sketch and it worked.
Reply 7 years ago on Introduction
Module Test: OK
AT+CWJAP="8xxxxxb","2xxxxxx9"
.....OK, Connected to WiFi.
.
yes it did work.!! now how can we add in the sensors and leds like here;
https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...
.
thank you so very much once again..!!!
Reply 7 years ago on Introduction
I replaced the function connectWIFI in the previous sketch. Please have a try.
https://gist.github.com/volca/da178cd000abb91d649f
Reply 7 years ago on Introduction
actually i think i solved the problem.
on the serial monitor the code never prints - debug.println("AT+CWMODE=1");
this maybe why,
-
Module Test: OK
AT+CWJAP="8xxxb","2xxxx9"
.....OK, Connected to WiFi.
temperature1019
light481
water0
SEND: AT+CIPSTART="TCP","184.106.153.149",80
GET /update?key=9TYUWTFXTYC9RKT8&field1=1019&field2=481&field3=0
Reply 7 years ago on Introduction
Change the line
debug.println("AT+CWMODE=1");
to
sendDebug("AT+CWMODE=1");
You will see it on the serial monitor. It's not the problem.
Reply 7 years ago on Introduction
how about this,
on my sketch; https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...
at the very end line, i have;
cmd = "AT+CIPMUX=0";
sendDebug( cmd );
if( Serial.find( "Error") )
{
debug.print( "RECEIVED: Error" );
return false;
}
you didn't include above part in your final sketch here; https://gist.github.com/volca/da178cd000abb91d649
i remember reading that this line is very important for successful upload. i tried including it myself but didn't still no success, i'm not sure where exactly it has to go however, maybe you can include it
.
also, looking at other esp8266 posts here, i notice that after AT+CIPSTART the monitor prints AT+CIPSEND=(a random number?)
when I used esp8266 rev-01 on my previous project this is what the serial monitor looked like - picture 1
picture 2 is how it looks like with your final sketch right now.. thingspeak channel still doesn't receive any data.
Reply 7 years ago on Introduction
I just added the code after line 63. Please have a try.