Automated Chicken Coop pt. 4 – Remotely Controlling our Coop pt. 3

Remotely Controlling our Chicken Coop pt3

Now it is we test our prior setup with the NodeMCU that we covered in the last post.

If you skipped the last section on setting up your NodeMCU with the Arduino IDE, go back HERE and follow the steps to get started.

Anytime you connect a new board to be programmed, I recommend finding a program like the one below to test your board before moving forward.  This will save you a ton of problems in determining if the board is correctly selected in the IDE and whether it will work.

Enter the following code into the IDE, click the Check Mark button to Verify the code will compile, then click the arrow to send the code to the NodeMCU.

The code below is known as a “blink” sketch.  Once again, I highly recommend always testing a board with a blink sketch before using it.

NodeMCU Test Code

void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)

If everything works correctly, the blue LED on your NodeMCU board should turn on and off.  This program is called “Blink” and can be found in your examples under File > Examples > ESP8266.   Blink programs are a great way to ensure you have connected to your boards correctly, and a starting point for understanding Arduino Programming.  Congratulations you’ve written your first program in Arduino – also known as a “Sketch”!


Leave a Reply

Your email address will not be published. Required fields are marked *