Hi everyone
I use charger cable to supply Nodemcu board
I want supply the board as soon as the power cut off by alternate source
But how to swich main source to alternate source?
connect main to the invertor or UPS or power bank and then power esp from it. so mains, is there are not does not matter. the nodemcu will always be powered by inverter or UPS or powerbank.
What are the pins S3, S2, S1, SC, S0, SK? Can I use them as GPIO in Nodemcu?
Thank you for your help!
i did not find any pins on nodemcu named S3, S2, S1. you can check here for which pin you are referring to ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials
Community Manager October 6
i did not find any pins on nodemcu named S3, S2, S1. you can check here for which pin you are referring to https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
Visit Topic or reply to this email to respond.
In Reply To
October 6
What are the pins S3, S2, S1, SC, S0, SK? Can I use them as GPIO in Nodemcu? Thank you for your help!
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
Did you check the link i shared above?
S3 ===> GPIO10 ===> pin is high at BOOT
S2 ===> GPIO09 ===> pin is high at BOOT
SPI
SD1 ===> GPIO12 ===> MOSI
SC ===> GPIO15 ===> CS
SD0 ===> GPIO13 ===> MISO
SK ===> GPIO14 ===> SCLK
I hope you know what does SPI stands for.
Hi i want to Connect Nodemcu board to my mobile phone using access point mode and control a led and monitor temerature .
My mobile app is wifi Controler that exist in google play…
I tried to write the code but I couldn’t. Please help me
what does the serial monitor output?
No problem in connecting the phone to the board … I just want to control an LED, for example if the phrase “on” is sent the LED will turn on … also monitor the temperature through the phone.
Have a look at this: Cayenne Docs
Hi
I would send ldr data from arduino to nodemcu by i2c connection and wire library. in this connection arduino is slave and nodemcu is master. But wire.write send only one byte while the ldr data is 2 byte…how to send 2 byte to master?
here a code to get you starting. you will need to add the cayenne code and sensor code.
Nodemcu receiver code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D2, D3); // RX, TX
void setup() {
Serial.begin(115200);
mySerial.begin(4800);
}
const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (mySerial.available() > 0 && newData == false) {
rc = mySerial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
parseNewData();
newData = false;
}
}
void parseNewData() {
char* val1 = strtok(receivedChars, "-");
Serial.print("val1 = ");
Serial.println(val1);
char* val2 = strtok(NULL, "-");
Serial.print("val2 = ");
Serial.println(val2);
}
Arduino sender code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(115200);
mySerial.begin(4800);
}
int h = 10;
int t;
String str:
void loop(){
t++;
h++;
str = String(t) + String('-') + String(h) + String('-');
mySerial.print(str);
mySerial.print("\n");
delay(5000);
}
Thank you but i need to i2c connection not serial connection
this code i had given to one of the user. for wire you will have to wait for some time.
How long it takes ?
can you try giving it a shot using wire library. nothing much will be changing in the above. And what is the problem in using serial connection?
hi
i changed your code but in slave when i try to send data in Wire.Write occure error!
this is my code :
for master:
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(D2, D3);
}
const byte n = 32;
char receivedChars[n]; // an array to store the received data
boolean newData = false;
void loop() {
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
recvWithendString();
showNewData();
}
void recvWithendString() {
static byte index = 0;
char endString = '\n'; //last of String
char rd;
while (Wire.available() > 0 && newData == false) {
rd = Wire.read();
if (rd != endString) {
receivedChars[index] = rd;
index++;
if (index >= n) {
index = n - 1;
}
}
else {
receivedChars[index] = '\0'; // terminate the string
index = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
parseNewData();
newData = false;
}
}
void parseNewData() {
char* val1 = strtok(receivedChars, "-");
Serial.print("val1 = ");
Serial.println(val1);
char* val2 = strtok(NULL, "-");
Serial.print("val2 = ");
Serial.println(val2);
}
and for slave :
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(8);
Wire.onRequest(requestfunction);
}
int h = 10;
int t ;
String str;
void requestfunction() {
Wire.write(str);
Wire.write("\n"); // '\n' send for determin last of string
}
void loop() {
t ++;
h++;
str = String(t) + String('-') + String(h) + String('-');
delay(5000);
}
and error title:
Arduino: 1.8.5 (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)”
WARNING: Category ‘’ in library ArduinoJson is not valid. Setting to ‘Uncategorized’
C:\Users\Sazgar\Desktop\Slave\Slave.ino: In function ‘void requestfunction()’:
Slave:20: error: no matching function for call to ‘TwoWire::write(String&)’
Wire.write(str);
^
C:\Users\Sazgar\Desktop\Slave\Slave.ino:20:17: note: candidates are:
In file included from C:\Users\Sazgar\Desktop\Slave\Slave.ino:1:0:
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:70:20: note: virtual size_t TwoWire::write(uint8_t)
virtual size_t write(uint8_t);
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:70:20: note: no known conversion for argument 1 from ‘String’ to ‘uint8_t {aka unsigned char}’
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:71:20: note: virtual size_t TwoWire::write(const uint8_t*, size_t)
virtual size_t write(const uint8_t *, size_t);
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:71:20: note: candidate expects 2 arguments, 1 provided
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:79:19: note: size_t TwoWire::write(long unsigned int)
inline size_t write(unsigned long n) { return write((uint8_t)n); }
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:79:19: note: no known conversion for argument 1 from ‘String’ to ‘long unsigned int’
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:80:19: note: size_t TwoWire::write(long int)
inline size_t write(long n) { return write((uint8_t)n); }
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:80:19: note: no known conversion for argument 1 from ‘String’ to ‘long int’
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:81:19: note: size_t TwoWire::write(unsigned int)
inline size_t write(unsigned int n) { return write((uint8_t)n); }
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:81:19: note: no known conversion for argument 1 from ‘String’ to ‘unsigned int’
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:82:19: note: size_t TwoWire::write(int)
inline size_t write(int n) { return write((uint8_t)n); }
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\Wire/Wire.h:82:19: note: no known conversion for argument 1 from ‘String’ to ‘int’
In file included from C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Stream.h:26:0,
from C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/HardwareSerial.h:32,
from C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Arduino.h:247,
from sketch\Slave.ino.cpp:1:
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Print.h:62:16: note: size_t Print::write(const char*, size_t)
size_t write(const char *buffer, size_t size) {
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Print.h:62:16: note: candidate expects 2 arguments, 1 provided
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Print.h:56:16: note: size_t Print::write(const char*)
size_t write(const char *str) {
^
C:\Users\Sazgar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\cores\esp8266/Print.h:56:16: note: no known conversion for argument 1 from ‘String’ to ‘const char*’
exit status 1
no matching function for call to ‘TwoWire::write(String&)’
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
have a look at this post NodeMCU I2C with Arduino IDE | NodeMCU
I have not problem in i2c…yesterday you sent me serial communiction code for connection between arduino…but i said to you i need i2c connection code that can send 2 byte by wire.write and you said me change this code… now i changed your code…
only my problem is wire.write error how to should change slave code for that no have error?
oh, sorry, have a look at this on how to send mutiple byte data i2c questions - sending multiple bytes to and from arduinos - Programming Questions - Arduino Forum