ThingSpeak and Arduino – pH and temperature, how to

in today’s short video we’re going to take two temperature sensors and a pH sensor and we’re going to couple that to an Arduino and then we’re going to upload that data to ThingSpeak cloud server and you will be able to on your phone see the temperature readings as well as the pH readings this is part of a series of videos on the Arduino microcontroller in aquaponics and hydroponics so let’s start right away so let’s have a look at our system block diagram again we start with our Arduino then we add our first temperature sensor our second temperature sensor and a pH sensor we that data will then go into the Arduino on analog ports A1, A2 & A3 and we will then send the data to esp8266 Wi-Fi model will then communicate that data via your Wi-Fi system to a cloud service called ThingSpeak where you can on the internet then on your PC have a look at the data and from there we will also send that data to a app on your cell phone where you can have the data with you all the time so if you ask how do you power your Arduino there’s basically two options the first is where a normal cell phone charger and you’ve used the same cable that you use for your programming and you just plug it into the cell phone charger and the other part into your programming port it also supplies your Arduino with five volts that it needs the second option is to use a DC adapter something like this and with a plug-in like this and you then plug that into your DC port, this is this port can handle seven to twelve volt so any decent DC adapter 7 to 12V adaptor you can use to plug in and to power your final project you can then install your project with that supply so here is our pH probe I’ll just put it separately but we’ll put it with the other components just now so you’ve got your probe you’ve got your analog interface board and from that you’ve got a positive five volt a ground and then on A3 you will put your analog output from the analog interface port let’s have a quick look at our circuit we’ve got our Arduino our ESP model let’s check the connections of the ESP module quickly or Rx of exp TX of Arduino TX of ESP to Rx of Arduino then common ground for the ground of the ESP model your VCC of your ESP model very important go to 3.3 volt then reset and CHPD is also connected like you can see to the VCC pin also your 1000uF capacitor is coupled close to your ESP between the VCC and the ground of the ESP module the capacitor of course to stabilize the voltage during short bursts of transmission of your ESP module then we go to our two temperature sensors one temperature sensor and the other one between that sensor and between that sensors middle point and ground you’ve got a 10k resistor then from there you’ve got the sensor and to the top is to five volt and then from the center point between those two you’ve got your wire that goes in this case to A2 so the temperature sensor 2 this one exactly the same coupling but your wire is going to A1 so the this is temperature sensor A1 and then all that’s left is our pH probe so you will see our pH probe probe is at A3 and that’s going to the pH boards analog output and then of course you need your file V positive which is from that trial there and our ground to move pH board so then you’ve got your five volt positive and you’ve got your ground that goes

also to your pH probe lets start with our build and we’re going to start with our ESP chip so I’m first going to put the connector of the ESP chip on the breadboard then you will see that this VCC reset and CHPD must be connected together so we’re just going to bridge them out on the breadboard is VCC and reset and I’m going to put another link on for between reset and CHPD so there is it the link there all right and then we can take that VCC and just get the wire we can connect to the 3.3 volt of our Arduino board make sure you put it into the correct place then the ground of the ESP chip we can connect to our system ground and let’s put our system ground on this rail of the breadboard remember if you do not know the breadboard the connections on the breadboard please check previous videos where I’ll explain that so the next thing would be to connect Rx and TX so TX of the ESP chip to RX of the Arduino that’s pin 0 and then Rx of the ESP chip goes to TX of the Arduino that pin 1 alright so we basically almost finished with ESP chip just one thing that we must add there is electrolytic capacitor remember the electrolytic capacitor has got a negative port that must go to ground of the ESP and the positive part must go to the VCC of the ESP so I’m just going to put this one on ground there to get it into that VCC and just make sure that it’s into the ground as well so there you go capacitor is in and our next thing is two sensors 10k thermistor so let’s start with that we’re going to connect the 10k thermistor between VCC and let’s make this a VCC rail here are five V VCC rail and 10k resistor just put them together there and we go to ground with that pin then the next one as well another thermistor also to VCC and let’s put it there and then with like other 10k resistor and we just go to ground from there right now that center point let’s make this thermistor one thermistor one this one so we’re going to just be the resistor and the thermistor legs are connected we take that then – I can see in the software I want we connect that to A1 right and then the other one as well so we can take the second thermistor the second thermistor with the thermistor and resistor is connected we take that to A2 will see that’s also in our software like that and then we get to pH probe here is our pH probe so I’m just going to put that to the side and you’ll see this is our analog interface board of the pH probe the analog interface board again is got a 5 volt VCC that we put on our 5 volt rail here and the ground which is a common ground we put on our ground and then the analog output value

of the analog interface board we put to Ai3 like we specified in our software so now we still need to connect now remember this is our 5 volt rail that we’ve specified here so we’re just going to put a wire from the 5V to our five volt pin on our Arduino, all right and then we still have to connect our ground so we take a wire for the ground which is this bottom rail here so we just put it in there and we take that to ground so you can see there is the complete connection with the two thermistor with our pH probe everything connected very easy to do that keep your connection diagram open next to you when you do that to that part in the video I’m going to go into a little bit more detail into the software today so the first part of the software here you can see that it’s two forward slashes everything behind that like we’ve said in the past is just comments so I’ve given a few comments here at the top and then after that there’s a few things that you must change in your software the first thing is the name of your Wi-Fi network then the second thing is your Wi-Fi password you put it in there and then the next thing is the channel key this one here very important you must get this channel key from ThingSpeak so if we go to ThingSpeak here you will see API keys you can just press on that tab and this will take you to your API keys and this is the API write key so you just copy this key and then you will go back to your Arduino program you will just from there until there paste the key in and that’s the key then so that your Wi-Fi knows exactly where to go and put the data the next point here is your time interval between your samples and you will see I’ve got it at one second here for the just for test purposes now but you will typically change this to the amount of seconds for 10 minutes or for 15 or for 20 minutes depending on the sample interval that you want to use the next thing here is our ThingSeak IP now this IP address stays exactly the same you don’t bother with that and then we have to find a few variables you can see that temperature one we’ve put on the A1 analog port temperature – we’ve put on the A2 analog port and then our pH we’ve put on analog A3 and then again a few variables that we work with yes our calebration factor for our pH probe please check the video on the pH probe to see how to calibrate it I’m not going to do this in detail in this video please check the video on the pH probe if you want to calibrate your pH probe that must be done the next part is the setup so this is our serial communication baud right at 115200 please make sure that you put your serial monitor to baud rate as well at the bottom of the serial monitor you’ll find that then there’s just a little test to test if a Wi-Fi module is working our esp8266 so the next thing is a main loop remember all my software I write in the form of functions that I call from the main loop there’s four main functions that I call from the main loop in this case first I will get the temperature one value then the temperature two value then I will get the pH and then I will send that by the Wi-Fi and then I will wait a certain amount of time I remember the time that you’ve set at the top that variable is going to be placed in this time is

placeholder your delay is always in milliseconds so this is why it’s 1,000 times the variable that you’ve defined in so to get to seconds and then we’ve got our different functions yes the pH function you will see if you click on the first bracket below that and you move down the last bracket of that function will be just indicated by the IDE like you can see there so everything in between there and there is part of that specific function what we do in the pH function I’ll take ten readings and then I average them and then I do a calculation to calculate exactly the pH value and I put that value then into this variable pH value right let’s move on to temperature one this is the next function again it starts there this one will read the temperature on this analog port now remember temp one at the top we’ve set that to A1 so it’s going to read it on A1 the in temperature – exactly the same so it’s going to read it on this analog port which is A2 and yes our send function our send function will do a certain amount of things in order to send that data via the Wi-Fi to the cloud server ThingSpeak now I just want to bring your attention to something yet they yes your different fields so you’ll see that’s field1 field2 field3 i’ve commented out field four to eight but you can always add this in if you’ve got more sensors that you want to read from and send data to things pick and let me show you that line will stay the same this one will stay the same and then here can you see I’ve put a variable for temperature one in here I’ll put a variable for temperature 2 in jere and I’ve put the variable for the pH in here so those variables will be sent to those fields in TthingSeak and then we just end of the AT commands communication to the Wi-Fi module and that’s the in the end of this function here you will see what Wi-Fi connect function the Wi-Fi connect function is called in this send function right all in all a very simple program you can then just compile it and see if it compiles and you can see it’s busy compiling done compiling so there’s no errors in your program normally if I do any changes to a program I will immediately compile this check for errors and then fix that errors before I move on so we’re ready now to upload to the board and just remember your or RX TX wires on your Arduino board you must lift those out before you upload to the board because the communication her is also happening here on the wire that’s the zero communication for the UNO and if you leave the wires in while you program then it will not program correctly so I’ll just lift them out keep them and then to the upload and you’ll see it’s uploading it’s done upload and we can push a wire back the right so now that program is running on on our microcontroller and we can now go to ThingSpeak so there you can see the data coming into ThingSpeak for temperature 1 and field 1 temperature 2 in feld and then our pH here you can see I’ve constructed a gage here for the pH there is a specific video on ThingSpeak where I’ll tell you most of the stuff that you need to know you know how to construct this gage as well so this is our pH readings as they come in there you can see one just came in and then let’s take our temperature I’m just going to touch the I’m just going to touch the temperature sensors to heat them up a little bit so that we can see

that data from the temperature sensors rising and you can already see some movement in the temperature sensors in the temperature that’s read by our Arduino system and there you can see the temperature moving up so your system is now 100% working your logging your pH so you can also make gauges for your temperature 1 and temperature 2 in ThingSpeak I just want to show you how to work with the TingSpeak apps on your Android phone so you can just go to the Play Store and then you can just type in ThingSpeak and you’ll find our range of apps that you can use with this with the system I’m using two at the moment thingviewer and thingshow so I’m just going to show you the thingshow so here you can add a channel so you can just press that plus I’m going to add my public Channel and then I need channel ID so let’s go to the channel itself and at the top of your channels you’ll find the channel ID of that specific channel that you want to show in the app so this one is 432244 I can then just go 432244 I can open that it will then tell me alright these three different fields in that channel just go ahead and now you can see my channel appear there so if you just press on that channel then it will open and you will be able to see your data and you will see that it correlates with your channel so there is a channel and is it on the phone now after your project is working you can take it and you can just build it on a Vero or strip board, you can maybe put it in a little box like this one and another thing that you can do is if your project is in your system you can just plug out your pH probe and you can plug it in when you need to take pH readings remember pH probes does not have a long life so if you leave it into your system permanently it would not last longer than about six months you can just check the manufacturer specifications on a specific pH probe that you use but I normally take my pH probe out of the water and if I want to do pH readings I put it in the water the data is nicely locked in the cloud so I’ve got the record of that but otherwise the probe is not in the water you can also check out the videos on the screen right now I’ve also linked the playlists there for you for the other or Arduino videos if you like this video if you found any value in it please like it subscribe and I will see you in the next video thank you and bye bye