So this is my first time working with ESP32 or any MCU at all and I'm trying to blink an external LED connected to my GPIO16 pin but it doesn´t seem to be working. My board is a 38pin ESP32 with only one internal LED connected to pin 1 (not to pin 2 as many other esp32 dev boards) which I was actually able to blink with the blink example program.
I've tried connecting my external LED positive terminal to GPIO17 and GPIO18 as well but still doesn't work. I'm grounding my LED negative terminal with one of the GND pins of the dev board and I've also tried using the other 2 GND pins available but the result is the same.
In the Arduino IDE I'm using ESP32 Dev Module as my board in the boards manager and the serial communication seems to be working just fine, I'm just not being able to output the HIGH and LOW signals to light up my LED.
The limiting resistor I'm using is a 220 Ohm.
Here's the code I've been trying to achieve this:
int ledPin = 16;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop () {
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
delay(1000);
}
Is it possible that my pins are outputting a very low voltage or that they might not work?
I leave a picture of my pinout. Thank you very much in advance!!
ESP32 Dev Module 38 Pin Layout
Related
I am trying to get my SIM800C to talk with my Arduino. There is no communication happening, though.
#include <SoftwareSerial.h>
SoftwareSerial at(2, 3);
void setup() {
Serial.begin(9600);
at.begin(9600);
}
void loop() {
// try every 2 seconds
delay(2000);
Serial.println("sending AT ... ");
at.println("AT");
while (at.available() > 0) {
Serial.write(at.read());
}
}
I am not able to get an OK back. SIM800C is supposed to detect the baud rate by itself.
I am sure there has to be a simple stupid mistake. I just don't know what to do at this point. I obviously already checked for cable break. Out of desperation I already tried to switch RX and TX. I also tried different baud rates (whatever is within the usual limitations of SoftwareSerial) but it should automatically detect it once a couple of AT commands got in anyway.
Weird enough, the pin PWX on the SIM800C needs to be hooked up to a GND to work. It started blinking every second now and is responding to AT commands.
Also it turned out that this specific module does not ship with autobauding enabled, as stated by the SIM800C documentation. The correct baud rate is 115200.
There are some problems you need to consider:
Use below sample code which transfers data between PC and SIM. Sometimes SIM module would go into power down state and won't respond on any AT command but would print some results in the serial monitor.
As already mentioned in comments it seems that your wiring is wrong and as you declared Software Serial as SoftwareSerial at(2, 3); which means pin 2 is Rx on Arduino and should connect to Tx pin of SIM and pin 3 is Tx on Arduino and should connect to Rx pin of SIM. Please don't mess with the pins and connect the pins like below correctly.
Arduino SIM
Rx 2 ----> Tx
Tx 3 ----> Rx
I'm not sure if you can power on SIM800 with a 500mA USB connector, make sure that use an external 1/2 A power supply for VCC of SIM module.
Look at the blink speed of SIM module if it connected and powered on it would blinky with 3 seconds delay and if it blinks fast, it means that it is being restarted. Also if SIM powered on correctly it would print some info like SIM READY, CALL READY, etc.
Try other baud rates like 115200 and see if you get anything on power on.
I put some macro definition to make pin mappings more clear.
#include <SoftwareSerial.h>
//SIM800 TX is connected to Arduino D2
#define SIM800_TX_PIN 2
//SIM800 RX is connected to Arduino D3
#define SIM800_RX_PIN 3
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
void setup() {
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);
//Being serial communication witj Arduino and SIM800
serialSIM800.begin(9600);
delay(1000);
Serial.println("Setup Complete!");
}
void loop() {
//Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
Yes this module will not work in this configuration. There is a pin of V_TTL With 5V pin.. This pin enables the TTL logic converter of your GSM.. You have to connect this pin to 5V in case of arduino and to 3V in case of ESP8266.See the pin configuration here
I bought this board
As far as I can tell I installed the drivers and libraries properly(I can see the board in the usb devices and upload the code), but every time I try to run a program, I get this result in the serial monitor and the board doesnt light up any led. I also tried to just print an hello world, but i get the same result.
My configs are :
And a example is:
I hope you can help me out, thank you!
I think the issue with the LED not blinking is because many of the ESP12 boards use GPIO 2 rather than GPIO 1 for the built in LED.
See this issue for more details.
Try adding this to the beginning of the sketch:
#define LED_BUILTIN 2
or just use 2 in place of LED_BUILTIN
which will re-define LED_BUILTIN to use gpio 2 rather than gpio 1
As for the serial monitor, I have not directly used the Arduino IDE in a while, but you are not printing anything to the serial port anyway.
Here is an updated version of the sketch that should blink the led and print some messages to the monitor. (set the baud rate of the serial port to 115200 in the IDE)
#define LED_BUILTIN 2
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
Serial.println("turning ON LED");
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-01)
delay(1000); // Wait for a second
Serial.println("turning OFF LED");
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)
}
The problem in my case was a faulty board. I requested a new one from the seller, and the one worked just fine with the code that I provided in the question.
I have purchased a brand new Arduino Uno today. While it was connected to the PC, the LED (pin 13) was always remaining on. I have uploaded a blank program, but the LED doesn't go off.
Help me with this issue, please. I am in a fix about it.
The Arduino does not remember any states which have been set before a new program start. Without setting the digital port 13 the LED is turned on. You can set the port 13 by program (using it as output port) or you pull down the port by connecting it to ground (using it as input port).
Also see tutorial about digital pins on the Arduino website.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
}
I'm playing with Arduino and I've tried a simple circuit where an LED lights up when you press a pushbutton, using the attachInterrupt() function.
Here is the code:
const byte LED = 11;
const byte Pushbutton = 2;
// run setup code
void setup() {
pinMode(Pushbutton, INPUT);
pinMode(LED, OUTPUT);
attachInterrupt(digitalPinToInterrupt(Pushbutton), LEDManager, CHANGE);
}
void loop() {}
// <summary>LED manager HIGH or LOW</summary>
void LEDManager() {
digitalWrite(LED, digitalRead(Pushbutton));
}
My circuit works but intermittently or when I touch the wire connected to pin D2.
I don't understand why and I need some help!
Update
I've tried many configurations and when I use new wires it works! The problem was welds, they were not well done and had probably damaged the wires (my soldering iron was too hot).
(Spoiler, a new fail! Wow!)
Update 2!
This time, I changed the circuit and connected pin D2 to the COM port of the pushbutton. The COM port is connected to a 10k ohm resistor that is connected to the Gnd pin and 3.3V pin is connected to the ON port of the pushbutton (I was inspired by that, thanks ingo).
It's finally working, alleluia !
I changed the circuit and connected pin D2 to the COM port of the pushbutton. The COM port is connected to a 10k ohm resistor that is connected to the Gnd pin and 3.3V pin is connected to the ON port of the pushbutton (I was inspired by that, thanks ingo).
I bought a new ESP8266 WIFI module (8pins) and flashed firmware (from https://raw.githubusercontent.com/nodemcu/nodemcu-flasher/master/Win32/Release/ESP8266Flasher.exe) it using arduino Duemilanove correctly.
I have gone through many troubleshooting steps, but on reset module does give some gibberish response, but no Ready/OK response from "AT" command.
Red LED
of module is always on but Blue light is off.
Steps taken :-
To supply enough current i used Beaglebone 3V3 supply as module Vcc.
But i'm not able to receive any response from AT commands.
Arduino Tx (5V) has brought down to 3v3 using voltage divider and
connected to Rx
In Flash settings ensured baud rate was 115200 and all settings correct
Module is working fine presumably as tried with 2 more modules same thing
Here's my connections:
//////////////////////////////////////////////////////////////////////////////
/////// CONNECTIONS ////////
/////////////////////////////////////////////////////////////////////////////
/*
ESP8266 VCC -> BeagleBone 3.3
ESP8266 GND -> Common GND (Arduino & BeagleBone)
ESP8266 CH_PD -> 3K resistor -> VCC
ESP8266 RST -> VCC or pin 13(arduino)
GPIO CAB BE LEFT OPEN OR TIED HIGH
ESP8266 Tx -> pin2 (Arduino software serial Rx)
ESP8266 Rx <- Voltage Divider <- pin3 (Arduino software serial Tx)
*/
Here's my code
#define esp8266 Serial2
#define CH_PD Vcc // but needs a narrow low pulse
#define speed8266 9600 // This is the speed that worked with my ESP8266
void setup()
{
esp8266.begin (speed8266);
Serial.begin(9600);
reset8266(); // Pin CH_PD need a reset before start communication
}
void loop()
{
while(esp8266.available())
{ Serial.write(esp8266.read()); }
while(Serial.available())
{ esp8266.write(Serial.read()); }
}
/*************************************************/
// Reset funtion to accept communication
void reset8266 ()
{
pinMode(CH_PD, OUTPUT);
digitalWrite(CH_PD, LOW);
delay(300);
digitalWrite(CH_PD, HIGH);
}
Here's the output on Serial Monitor
Arduino Serial Monitor Output
Kindly help me what am i doing wrong ?
I don't want to use another FTDI chip while arduino already have it.
At the moment I can only give you a part answer (seems I can't comment yet :) ).
The gibberish is normal when starting/resetting the ESP, it's just the boot code which outputs a boot message at 74880 baud (Which is basically the default baud rate 115200, but because the ESP starts at a lower cpu frequency, the baud rate is also lower, boot frequency is 26 mhz, normal frequency is 40 mhz, 26/40 * 115200 = 74880. If you can set your serial client to 74880 baud you should see the message, but it's an odd baudrate, so it might be hard or impossible to set.
So gibberish on reset is good! It means the ESP is working and happy, the problem is with your software (as you determined yourself too).
I assume your code is on the Arduino side?
The big question is what is flashed on the ESP, and what it's expected bahaviour is. From your question I'm not 100% sure what you did flash on it..
I think you might've flashed nodemcu on it though, which would not respond to AT commands, try to flash the 'original' AT rom from Espressif Systems on it?