Introduction: Arduino Wifi Temperature Logger

Picture of 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

Picture of Materials

The Cactus Micro is an arduino compatible dev board, it integrated a WIFI chip ESP8266.

Step 2: Connecting the Wires Together

Picture of 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

Picture of 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.

Comments

herneise (author)2016-11-26

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)

yanc (author)herneise2016-11-29

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

OlexS (author)yanc2016-12-13

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;

}

anthonyjclarke (author)2015-12-20

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

yanc (author)anthonyjclarke2015-12-20

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.

UkritK (author)2015-05-12

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

yanc (author)UkritK2015-06-04

You should compare it with Arduino Leonardo or Arduino Micro. The micro controller is ATMega32U4.

Akin Yildiz (author)2015-04-07

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...

yanc (author)Akin Yildiz2015-04-09

It looks great! I

yanc (author)2015-03-12

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

Akin Yildiz (author)yanc2015-03-13

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

yanc (author)Akin Yildiz2015-03-13

For test WIFI connection, please make it simple. Run the sketch below.

https://gist.github.com/volca/69c559cfb50e5580668c

Akin Yildiz (author)yanc2015-03-13

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..

yanc (author)Akin Yildiz2015-03-14

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.

Akin Yildiz (author)yanc2015-03-14

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..!!!

yanc (author)Akin Yildiz2015-03-14

I replaced the function connectWIFI in the previous sketch. Please have a try.

https://gist.github.com/volca/da178cd000abb91d649f

Akin Yildiz (author)yanc2015-03-14

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

yanc (author)Akin Yildiz2015-03-14

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.

Akin Yildiz (author)yanc2015-03-15

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.

yanc (author)Akin Yildiz2015-03-15

I just added the code after line 63. Please have a try.

Akin Yildiz (author)yanc2015-03-17

again, it doesn't compile - this time line 70 is highlighted and it says;

return-false;

error: return-statement with a value, in function returning 'void'

.

感谢您的时间 :)

yanc (author)Akin Yildiz2015-03-17

Ah. I replaced the "return false;" to "return;". Then everything goes well. I just compile the sketch and success.

Akin Yildiz (author)yanc2015-03-17

yes, it compiled and uploaded to cactus micro, but still no success on thingspeak.com. check out this picture;
.
everything seems like it is working. what about line "AT+CIPSEND=" what is this random number next to it.? i remember with the esp rev-01 i would get different numbers on the serial monitor when the device worked and didn't work.

also AT+CIPSTART in our new sketch is different, it shows up as SEND: AT+CIPSTART.. ?

it connects to wifi, but doesn't upload, maybe it never gets a successful connection with thingspeak.com

yanc (author)Akin Yildiz2015-03-18

I move the code to the link. https://raw.githubusercontent.com/volca/cactus_mic...

I think the cactus micro need a simple library to handle http request. It will be more friendly for newbie.

Akin Yildiz (author)yanc2015-03-19

you did it..!!!! finally uploading successfully :)

here is the channel; https://thingspeak.com/channels/18259

this is the cheapest cloud updating, analog sensor, with onboard wifi chip, arduino programmable device in the world right now :) and you did it all - thank you so much yanc.!! i will be making a detailed post soon, i will let you know..

.

what was the problem do you know? also if you can make a library for analog sensors and how to upload them online to thingspeak would be great. because with thingspeak you can connect a twitter account for e-mail updates/alerts or you can set up and app to control AC relays as well, all the cactus micro has to do is to read raw sensor data (no conversions, no libraries) and upload it to thingspeak. the rest can be done on the cloud based on this data.

.

also do you work for april brother company.?

謝謝

yanc (author)Akin Yildiz2015-03-19

Congratulation! It's almost done.

I have found some simple library for esp8266 and choose one for cactus micro. I'm also waiting for your new plant doctor project.

Yes. I work at April Brother.

Akin Yildiz (author)yanc2015-03-16

it doesn't compile, line 65 cmd = "AT+CIPMUX=0"; is highlighted and

'cmd' was not declared in this scope

yanc (author)Akin Yildiz2015-03-16

I made a minor change for line 65. It should be ok.

Akin Yildiz (author)yanc2015-03-14

worked.!!

Module Test: OK

AT+CWJAP="8xxxb","2xxxx9"

.......OK, Connected to WiFi.

temperature1010

light456

water0

SEND: AT+CIPSTART="TCP","184.106.153.149",80

GET /update?key=9TYUWTFXTYC9RKT8&field1=1010&field2=456&field3=0

temperature1010

light470

water0

SEND: AT+CIPSTART="TCP","184.106.153.149",80

GET /update?key=9TYUWTFXTYC9RKT8&field1=1010&field2=470&field3=0

temperature1010

light474

water0

...

however thingspeak.com doesn't recieve the numbers.. i will look into that later on. i should be able to fix that myself, if not i'll message you again.
.

i am going to do a detailed instructable soon, i will be promoting your work and cactus micro - will let you know !

thank you so much once again

Akin Yildiz (author)yanc2015-03-14

will try and reply in 3hrs

yanc (author)Akin Yildiz2015-03-14

You can upload the serialMonitor sketch to cactus micro. It's good for test AT command via Serial Monitor.

https://github.com/AprilBrother/cactus-micro/tree/...

Type in the Serial Monitor to test wifi connection

AT+CWMODE=1

AT+RST

AT+CWJAP="YOUR-SSID","YOUR-PASS"

yanc (author)2015-03-12

Please use Arduino IDE 1.0.x. Not 1.6.1.

All the AT command should send to SoftwareSerial _rxpin/txpin not "Serial". Because the esp8266 is connected to SoftwareSerial pin 11/12.

What Arduino board did you use early?

Akin Yildiz (author)yanc2015-03-12

i used arduino nano + esp-01, here is my work, it works real well; https://www.instructables.com/id/Envolysis/

.

but now we need to update the code for it to work with cactus micro. i have tried but no success; https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...

the code uploads to cactus micro using IDE 1.6.1, lillypad usb chosen. and the sensors work, they read data and turn on the rgb led correct color, no problem there, i just can't upload the data to thingspeak.

.

it has to be a code mistake, and most likely smtg to do with the software serial line.

.

thank you for your time,

yanc (author)Akin Yildiz2015-03-12

Please try with Arduino 1.0.6. I test under 1.6.1 but have some issues with SoftwareSerial.

yanc (author)2015-03-12

I will reply to you 8 hours later because it's too late. Please write your reply here. I will be back.

yanc (author)2015-03-12

The code will stuck if the cactus micro not connect to USB.

if(Serial.find("OK"))

{

debug.println("RECEIVED: OK\nData ready to sent!");

connectWiFi();

}

Dont use "Serial" for atmega32u4 when it havent connect to usb. I will give you a link from arduino.cc to describe it.

http://arduino.cc/en/Guide/ArduinoLeonardoMicro#to...

For instead, you can use the Serial1.

Akin Yildiz (author)yanc2015-03-12

by the way cactus micro was connected to computer usb earlier

yanc (author)2015-02-03

The SDK 0.9.5 for esp8266 support light sleep and deep sleep. But it need GPIO15 connect to RST and esp-11 module have no the pin GPIO15. So there's a way that set pin 13 of cactus to low to disable the esp-11. It will save power cosumption.

Akin Yildiz (author)yanc2015-02-09

what if we just put the entire cactus micro board on sleep mode, instead of just the esp chip.? is this possible, would it be easier and more battery life.?

yanc (author)Akin Yildiz2015-02-21

Here's a Sleep library to power saving for atmega32u4.

https://github.com/n0m1/Sleep_n0m1

You can found more examples at Github.

For esp-11 module, we need make a jump wire to use deep sleep function.

Akin Yildiz (author)yanc2015-02-21

can you confirm my wiring? i can't be sure, ur picture is a little blurry.. my cactus micro is still on the way. it's been 18 days, should be arriving soon :)
i will be asking you a few detailed questions once everything is plugged in and ready to go. i'm working on a printed case at the moment.

yanc (author)Akin Yildiz2015-02-22

Yes. You're right. I will make a clear photo later.

MK1888 (author)2015-02-08

Regarding your sketch: Note that Serial.find() is a consuming search; it reads the data from the serial buffer such that it can't be read again. So when you do mySerial.find("OK"), you can't then do mySerial.find("ERROR"). Search for one or the other, not both.

yanc (author)MK18882015-02-09

Thank you! I've removed the code mySerial.find("ERROR")

PeterK9 (author)2015-02-02

Out of interest, what's the battery life like for this project?

yanc (author)PeterK92015-02-02

It can run 24 hours+ with a 1000 mAh battery. The battery life will be longer if I optimize the upload time interval and enable sleep mode for esp8266.

Akin Yildiz (author)2015-02-01

i've just ordered a cactus micro thanks to you. i was waiting for spark photon to come out in march, but this is cheaper and smaller and better probably right :) great work, follow + favorite.

yanc (author)Akin Yildiz2015-02-01

Thanks. I will be glad to see your new project.

amberrayh (author)2015-01-29

Cool. Thanks for sharing!

About This Instructable

21,935views

83favorites

License:

More by yanc:Siri HomeKit Controlled ESP8266 LockBLE Rainbow LAMPArduino BLE Temperature/Humidity logger with DHT11 and iOS display
Add instructable to: