Unable to connect to WiFi with a Wemos S2 Mini clone? - arduino

I bought this Wemos S2 Mini three-pack from Amazon last week and I've been pulling my hair out trying to get them to connect to WiFi. I have the Ardiuno IDE 1.8.19 set to a LOLIN S2 Mini from Espressif 2.0.3 as directed, with Arduino WiFi 1.2.7, and am running this code:
#include <WiFi.h>
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin("ssid", "psk");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("Connected to WiFi network with IP Address:");
Serial.println(WiFi.localIP());
}
void loop() {
//
}
All I get is endless ........ in the Serial Monitor. I've tried:
running the esp32 WiFi Scan samples and all I get is "no networks found"
attempting to rename my router's ssid to something without a space
connecting to my phone's hotspot
flashing all three boards
choosing other random ESP32-S2 dev boards in the Boards Manager
several different USB-C to USB-C and USB-C to USB-A cables into my computer
No dice. Bad hardware? What am I missing?

Purchased an actual LOLIN S2 Mini from AliExpress, ran the same code, worked immediately. Don't buy these shitty knockoffs from Amazon.

enable "Verbose" in Arduino for compilation - you will get all the
messages/errors to start with
make sure your AP does not have white/black list for MAC addresses
ssid/password ok? (sorry, but sometimes it happens)

Related

D1 mini lite won't connect to WLAN

I am building some simple IoT devices like tem / humi and window sensors for the house and would need some support with a simple method to connect a D1 mini lite to my WLAN.
There are already more than enough examples and tutorials out there to do this and I was already successful to connect a D1 mini and a Raspberry Zero with the sensors and to my WLAN and post some messages on a local MQTT server.
It was pretty clear and easy to do this and worked as I was told for the D1 mini and the Rasp Zero, but the D1 mini lite just won't connect to my WLAN. I kept the sketch (see code below) very simple and tried the exact same code for D1 mini and the D1 mini lite. The mini connects and the lite won't.
I am using the Arduino IDE and installed the additional board manager from here: http://arduino.esp8266.com/stable/package_esp8266com_index.json
For the D1 mini I chose "LOLIN(WEMOS) D1 R2 and mini" and for the D1 mini lite I chose "LOLIN(WEMOS) D1 mini Lite" under Tools->Board->ESP8266 Boards (3.0.2) (seems to be the most current one according to github)
The IDE gave me no errors on compiling or transferring to the board. The blue LED blinked on both boards when transferring the compiled sketch and when plugin in USB.
The serial monitor shows the IP of the connected WLAN for the D1 mini after 2 or so printed dots. The D1 mini lite keeps on printing dots without ever connecting or showing any other error / exception.
Is there a way to check the functionality of the wifi functionality of the board or to see why it was not able to connect? Any hint or link to documentation is appreciated.
I am not aware of having to use another other WiFi framework for the D1 mini lite as the one I used in the pretty much copy and pasted sketch. If this is the case would someone please let me know where this is mentioned to avoid future problems.
As I am very new to C++ - did I miss anything obvious? Please let me know and I will add the information or correct my beginners fault.
#include <ESP8266WiFi.h>
char ssid[] = "wlanssid";
char pass[] = "supersecretpassword";
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.begin(ssid, pass);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {}
My settings in Arduino under Tools for the mini lite

Arduino Wifi Shield 101 Connection Issues

So I recently bought the Arduino Wifi Shield 101. I went through the getting started steps, and just copied and pasted their "scan for networks" code. The code that I used is down below. So to help you guys help me, I should say my school's wifi is wpa2 encrypted. However, the code is simply looking for possible networks to connect to. The code runs fine until it gets to the "Wifi.macAddress(mac)" line. I don't understand why the code stops working here. There aren't any errors in compiling or uploading, the code just seems to not be working. Im obviously a beginner with the arduino wifi board, so any help at all would be great.
Here's the code:
`#include <SPI.h>
#include <WiFi101.h>
void setup() {
// initialize serial and wait for the port to open:
Serial.begin(9600);
while(!Serial);
// attempt to connect using WEP encryption:
Serial.println("Initializing Wifi...");
printMacAddress();
// scan for existing networks:
Serial.println("Scanning available networks...");
listNetworks();
}
void loop() {
delay(10000);
// scan for existing networks:
Serial.println("Scanning available networks...");
listNetworks();
}
void printMacAddress() {
// the MAC address of your Wifi shield
byte mac[6];
// print your MAC address:
Serial.print("The code got to here");
WiFi.macAddress(mac); //why won't this method work?
Serial.print("The code never reaches this point ... Why?!?!?");
Serial.print("MAC: ");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.println(mac[0],HEX);
}
void listNetworks() {
// scan for nearby networks:
Serial.println("** Scan Networks **");
byte numSsid = WiFi.scanNetworks();
// print the list of networks seen:
Serial.print("number of available networks:");
Serial.println(numSsid);
// print the network number and name for each network found:
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
Serial.print(thisNet);
Serial.print(") ");
Serial.print(WiFi.SSID(thisNet));
Serial.print("\tSignal: ");
Serial.print(WiFi.RSSI(thisNet));
Serial.print(" dBm");
Serial.print("\tEncryption: ");
Serial.println(WiFi.encryptionType(thisNet));
}
}`
Are you powering the boards via USB? If so, you're likely experiencing an under-power issue.
My original answer was deleted (so I don't know what you can and cannot see), but the link to the Arduino bug I filed is here:
Arduino 101 + Wifi 101 Shield board freeze. #50
As it turns out, my board was simply under-powered as I was using a USB port rather than a wall outlet. I actually ended up using a different USB port and the scanNetworks example now works for me.
EDIT Actually, as it turns out, it was the USB cable. Either way, power was the issue.
I would recommend powering the board via a wall wart or choosing a different USB port and trying again.

how to get AT response from ESP8266 connected to arduino

I am fighting with ESP8266 wifi module and connecting arduino. After updating firmware to newest version i started to programm arduino to get data incoming from wifi. I saw many examples about maiking webserver via ESP8266 but none of them works for me.
ESP is connected to my Arduino Leonardo:
>
Arduino -> ESP8266
power 3.3V -> vcc
ground -> ground
tx -> rx (via logic level converter 5->3.3V)
rx -> tx (via logix level converter
power 3.3V ->gpio0 (without any resistors)
I made simple sketch:
void setup(void){
Serial.begin(9600);
Serial1.begin(115200);
}
void loop() {
if(Serial1.available())
{
Serial.println("WIFI IS AVAILABLE");
Serial1.println("AT");
delay(1000);
} else {
Serial.println("WIFI not available.");
delay(1000);
}
}
After executing it ESP8266 is powered (red led is on) and also every second blue led (blinks). That makes me sure that in fakt "AT" command is transmited to module. But there are also two issues:
i want to get response from esp - in this case word "OK". I tried Serial1.read() but it only reads one byte. Serial1.readString() makes my messages "wifi not available" and sametimes "wifi is available" as if for a while the connection would be unavailable
after uploading sketch to arduino and having powered esp8266 wifi module is always unavailable - i need to power the module off and on again to have it working.
Anybody please can help me?
What you need to do is change your approach a bit. Do not check if data is available. The trick is to send the module something and then check for data.
Do something like:
while (Serial.available() > 0)
Serial.read();
to clear the buffer before any command you want to send. Then send the command. Then check for data as a response.
Do not rely on that Blue LED as any indication. It is only an indication that the ESP8266 is busy using the WiFi in some sort of way, whether it is doing keepalives, initializing WiFi or whatever. It can be totally unrelated to whatever you are sending. If you do not receive a valid response then you must assume that there is comms issues between you and the module. One thing though is that if that Blue LED never goes off then either the module has frozen or the firmware was corrupted. I have had that many times. I then reload the firmware and usually that fixes it. It usually only happens during development times where I reset, upload code or change wires.
I use mine with an atmega328 on a separate slef-built board and not the one on the Uno and run that board on 3.3v itself and then use a logic level converter between that atmega board and my Uno so that I can program it. But I have had sporadic issues with non-comms but I suspect it might be power related. Be aware that running your Serial via the logic level converter might also be causing comms issues.
Proposed wiring: All pins except RX,TX,VCC and GND goes to VCC via 10K pullup resistors. RX goes to the arduino's TX and TX goes to the arduino's RX. Of course you know where VCC and GND goes.

Serial Communication over Desktop to Arduino

I have a USB 2 Serial adapter and the device is working fine. I see the device perfectly configured in my System.
I have connected the TX0 pin of Arduino to DB 2 pin (read pin) of the adapter. Below is my Arduino code:
int i = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for(i=0;i<6;i++)
{
Serial.write('H');
delay(100);
}
}
But when I try to read thru terminal software of data received at my COM port I see some junk character incoming. I am pretty sure that I am using same baud rate / flow setting both side. Why am I facing this issue - do I need to connect any other pins also as I just need to receive data at system side?
You should connect the ground pin with the ground pin
Arduino Communicate with Ur computer using pins 0 and 1( Tx0 and Rx0)
you shouldn't be connected to the Tx0 pin to another serial device because arduino use it to communicate with computer.
if you are using Uno. Check for Software Serial. and two grounds should be connected.

Receiving Response from Serial Device in Arduino MEGA

I am a newbie with Arduino Mega 2560 .I have been trying to connect the Arduino and SIM900A module(GSM/GPRS module).I have connected the USB to my PC(Serial instance) and pins 18(Tx) and 19(Rx) to Rx and Tx in the GSM/GPRS module respectively and the GND pin(GSM/GPRS) module's is connected to GND,one near pin 13 in the Arduino.
Power connection:-
I am powering using 12V supplies for each of the boards.
The below is my code.
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
delay(1000);
Serial.print("Initial Setup !!");
delay(5000);
}
void loop()
{
if(Serial.available())
{
char a=Serial.read();
Serial1.print(a);
//Serial.print(a);
}
if(Serial1.available())
{
char B=Serial1.read();
Serial.print(B);
//Serial.print(a);
}
}
I am able to get the initial response in the "Serial Monitor" like (+CFUN:1,+CPIN:READY)(Once I open the Serial monitor I used to press the reset in the GSM/GPRSmodule).
But when I type some AT commands in the Serial Monitor,I am not able to get the response like "OK" from the GPRS/GSM Module.
Please let me know what I should be doing for getting the responses back from GSM/GPRS module.
Have you tried cutting out the Arduino, for just a moment? Get yourself a UART and wire up TX/RX to the GMS respectively. Then plug it into your PC and launch terminal (Tera Term, etc.).
Try issuing some AT commands and make sure you're getting correct responses/echos. You may also want to try a tool called QNavigator (free download).

Resources