Iv read a number of posts on Interfacing arduino with bolt .
Let me explain my current scenario .
I have a program which utilises a moisture sensor and a water pump , the moisture sensor is suppose to trigger the pump at a certain threshold value , quite simple …or so i thought .
Turns out that the bolt cannot use the moisture sensor directly , i kept getting a reading of 1024 whether the sensor be placed in air or water .
After further looking up i found out that the bolt only supports sensors upto 1V and the moisture sensor uses 5V , which explained why my value was always 1024 . The Arduino uno on the other hand is fully capable of sensing values upto 5v and was giving me the values i needed to see .
I have the following queries regarding this process ,
1) How exactly do i go about integrating the moisture sensor with bolt using arduino to sense values ?
2) In doing so would i have to change the python code which i have written in my Virtual Ubuntu ? if so , then what changes have to be made ?
3) I did some looking up on the process , and forgive me for my lack of intuition if this seems stupid but hear me out…
I realised that we have to use bolts arduino helper library in the arduino IDE to help bolt communicate with the arduino , but my code is on my virtual ubuntu device … im not really sure if im expected to re write my code in the arduino ide ? if not like how is this process suppose to help me get my program to run
This process was quite frustrating to me , and CHEERS to whoever takes the time to elaborate and explain to me whats going on and what im suppose to be doing .
The code and connections for this project are as follows
import conf from boltiot import Sms, Bolt import json, time minimum_limit = 921 maximum_limit = 1024 mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID) sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER) while True: print ("Reading sensor value") response = mybolt.analogRead('A0') data = json.loads(response) print("Sensor value is: " + str(data['value'])) try: sensor_value = int(data['value']) if sensor_value > maximum_limit or sensor_value < minimum_limit: response = mybolt.digitalWrite('0', HIGH) print("Making request to Twilio to send a SMS") response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value)) response = sms.send_sms("MOTOR turned on") print("Response received from Twilio is: " + str(response)) print("Status of SMS at Twilio is :" + str(response.status)) else: response = mybolt.digitalWrite('0', 'LOW') print("Making request to Twilio to send a SMS") response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value)) response = sms.send_sms("MOTOR is in off condition") print("Response received from Twilio is: " + str(response)) print("Status of SMS at Twilio is :" + str(response.status)) except Exception as e: print ("Error occured: Below are the details") print (e) time.sleep(10)
CONNECTION (before arduino)
I would really like to know what changes i have to make in the code and circuit if i have to get it to work .