communication between eps8266 and pir sensor

so ive been trying to figure out how to control some Philips hue lights i have with a eps8266 Arduino Nano and a pir sensor with the code i have i can connect to my wifi and tell the light to constantly turn on however im having trouble integrating the sensor i have the esp8266 hooked up to the Nano correctly. With the pir sensor as it stands i have vcc hooked up to 5v grnd to grnd and the data line to d8 on the Nano. What im asking is how can i get the sensor to communicate with the Nano properly so the eps8266 can control the lights how its supposed to does anyone have any code examples of communicating between the 3?

A PIR sensor does not communicate, it makes an output go HIGH or LOW when it senses IR Heat.

so is there a way could i do something like if it senses heat output built in led on sensor High if senor on build in led high send change the script thats sent to the bridge but i guess my question is what would an example of this code look like i can code with python im just not familiar with the what ever language arduino uses

nick_d12:
so is there a way could i do something like if it senses heat output built in led on sensor High if senor on build in led high send change the script thats sent to the bridge but i guess my question is what would an example of this code look like i can code with python im just not familiar with the what ever language arduino uses

Try it again in English.

is there an example of code i could use to make this work? Im not used to arduinos coding language.

Then you need to read and learn, like the rest of us had to. The examples provided with the IDE will help a lot.

also do you program the nano and esp separately or can i write the program all in the same code?

nick_d12:
also do you program the nano and esp separately or can i write the program all in the same code?

You don't even need a Nano. The ESP can do the whole job. If not, the Nano communicates with, and commands the ESP via serial, with the ESP's built in AT command set.

I suspect the project is way over your head. Try some simpler projects to gain more experience.

probably but i do intend to finish what i started, and its the little esp so im using nano to communicate with the pir and use it as a power supply. so for example i have built a project where i control the pir sensor with the nano it lit up an led and i can turn the lights on and off with the esp depending on what the code is basicly true or false turns it on and off but if i go to program both under board do i select esp8266 or the nano?

I feel your pain. I get stuck on this stuff all the time.

aarg is correct, you shouldn't need the nano and it may be simpler to pull it out of the assembly. Are you looking for this to be a stand-alone project or are you integrating with something like Home Assistant? If the latter, this gets a lot easier. If not, how are you triggering the light from the ESP8266?

In simplistic terms, the code on the ESP will sit there monitoring the PIR active pin, waiting for it to go HIGH. When that occurs, it runs a loop that sends a signal to turn the light on, most usually for a pre-configured amount of time. If the PIR senses continued movement, it just keeps the pin HIGH so make sure you add a check to the end of the loop to confirm if the pin is still HIGH or has gone LOW. If it is still HIGH, re-run the code in the loop. If it is LOW, send a command to turn off the light.

The voltage for the PIR gets drawn directly from the ESP at 5V or 3.3V depending on your PIR requirement.

I don't have a spare PIR on hand or I'd take a look for you.

its the little esp

What exactly do you mean by that ?

if i go to program both under board do i select esp8266 or the nano?

You cannot program both at once, so select the board that you want to program and the corresponding port

If you want to have both sketches open in the IDE at the same time with the ability to upload to either at the click of a button without having to select the board and port then open 2 instances of the IDE and each can have its own board type and port

but see thats what confuses me and thank you for being patient with me in my code how would i make this work if if i can only program one lets say i do something like this

val = digitalRead(inputPin); (so im getting the information from the nano)
if (val == HIGH)
(i need to send a http client here)

so i guess im confused on how i program them independently but make the code work together

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.