I am trying to change the wires i2c pins to 11,12 (SDA, SCL). I built my own PCB but do not have the i2c lines in the same location. I used adafruits feather52 bootloader.
I found online that changing the variant.h file changes the i2c lines, but I don't have that file on my computer (PC), although my mac does.
I have tried the Wire.begin(SDA, SCL) though that's for the esps
I also tried to edit the wire.h files in both the default wire under C/programs/Arduino and the one under user/AppData/Arduino/adafruit though I haven't found where the pins are set.
The hardware packages are istalled into the Arduino15 folder. The location of the folder on Windows is in users home directory in C:\Users\\AppData\Local\Arduino15\packages.
The variant file is in variants/feather_nrf52832/variant.h
The nRF52 MCU can use any pair of pins for I2C.
So try to change in variant.h
#define PIN_WIRE_SDA (25u)
#define PIN_WIRE_SCL (26u)
to pins you need.
If it works, consider to define your own hardware definition instead of patching the variant.h.
You can't change the hardware I2C pins. They are hardware. That means that they are physically connected inside the chip to the part that drives the I2C. You can use a software I2C to "bit-bang" your communication. But that won't use the regular wire library.
You have a solution though. I was facing the same problem two years ago, and what I ended up doing was using software I2C. It "Bit Bangs" the I2C protocol on any digital pins of Arduino. There are couple of libraries for that. For example, check this one:
https://github.com/Testato/SoftwareWire
Start reading about I2C protocol and try to understand what the library is doing. Then it is possible to simulate the I2C protocol on the GPIO pins you have hardwired
You don't need to change NOTHING to use the Adafruit_SSD1306.h library.
If you're using a generic chinese OLED display, your problem is its address.
By default, the address of the 128x64 is 0x3D and if you have a 128x32 one the address is 0x3C, but chinese displays uses 0x3C on both sizes.
So look up for the line
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
and change it for this:
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Then, on your setup function, add Wire.begin(SDA_PIN,SCL_PIN); line replacing SDA_PIN and SCL_PIN with the pins you want to use, adding D before the number, like this:
void setup(){
Serial.begin(115200);
Wire.begin(D3,D4); //To use D3 as SDA and D4 as SCL pins, for example.
those are the only changes you should do. Tested on chinese generic display and NODEMCU made by AMICA.
Related
I'm working on a project in which there is a server and several clients (ESP32). In short, It's client-server communication over WIFI. Right now, I'm using ESP32-wroom-32D. In future, for a client device, I might use some other Arduino device or other ESP32 module or a combination of both. For code simplicity, I shall be using the same code for both types of devices (Arduino/ ESP32) as they support a common Arduino platform. Therefore, I want to know if there is a way which I can get the device's information.
Eg.
Function: Get_device_details( ) or Get_device_id( ).
Output: "ESP32-Wroom-32D" or "Arduino Mega 2560"
The Arduino defines to identify a board are in form of ARDUINO_<board>, where <board> is the value from <x>.build.board from boards.txt for board <x>
For example for Arduino AVR boards, in the boards.txt file is uno.build.board=AVR_UNO so the define is ARDUINO_AVR_UNO.
And Arduino has 'architecture' identification define too. This has form of ARDUINO_ARCH_<arch.name>. The <arch.name> is the uppercase version of the folder name with the boards package version. For example AVR for packages/arduino/hardware/avr/1.6.21.
For esp boards, you can use the following arduino code to get chip ID,
#ifdef ESP8266
int chip_id = ESP.getChipId();
#elif defined(ESP32)
int chip_id = ESP.getEfuseMac();
#endif
I'm trying to use the Adafruit Fona Mini GSM together with the Nucleo L073RZ. There exists a library for the GSM module, but it's for arduino. I've setup the board manager url to make use of the link in this repository: https://github.com/stm32duino/Arduino_Core_STM32/blob/master/README.md to add support for the MCU I'm using.
It's not possible to use SoftwareSerial together with this MCU it seems like. The library disappears when the card is selected. The GSM library supports HardwareSerial by uncommenting some lines though, which I've done. Unfortunately the MCU is unable to communicate with the GSM module.
Tera Term image
This is how everything is connected.
Hardware image
In case it's not apparent by the picture, this is how the GSM module connects to the MCU.
Vio connects to 5V
GND connects to GND
RX connects to TX/D1
TX connects to RX/D0
This is the only code modification I've made in the FONATest example, just to use hardware serial instead of software serial.
// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three
lines
// and uncomment the HardwareSerial line
//#include <SoftwareSerial.h>
//SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
//SoftwareSerial *fonaSerial = &fonaSS;
// Hardware serial is also possible!
HardwareSerial *fonaSerial = &Serial1;
I have designed a ledstrip driver capable of receiving commands over UDP-IP. I initially worked with an Arduino MEGA, and currently I'm in the process of deploying the code in an Arduino NANO.
The Arduino NANO only has one hardware serial interface, unlike the MEGA, which has several. This forces me to disable the usual debugging through one of the Serial ports (by sending strings to the computer) and to reserve the one and only serial interface for the ESP8266. In short, I am connecting the ESP8266 to the TX and RX pins in the NANO.
I am aware that I could use the softwareserial.h library, but I'd like to avoid it if possible.
The following function sets up the Wifi object:
void wifi_setup(){
// Initialize serial for ESP module
Serial.begin(9600);
// Initialize ESP module
WiFi.init(&Serial); /* GETS STUCK HERE */
...
}
The problem is: the microcontroller gets stuck in the Wifi.init() function and never abandons it.
I am aware that the serial interface is connected to the USB port, and am suspicious this might be a problem. However, I have tried giving power to the NANO through the VIN pin instead of through the USB port, and it hasn't worked.
What am I doing wrong?
The best solution will be to write separate code for ESP8266 and Arduino Nano - or even only for ESP8266 (NodeMCU to make it easy). It will be much easier. But if you really want to do it in your way, i think ESP uses 115200 baud, and you've set it to 9600.
Is it possible to run a serial port (soft or hardware) that only reads? The examples I see all involve two pins for read and write. I would like to use the TX pin for something else.
Here is a version of the SoftwareSerial library with the TX parts gone:
https://github.com/jbeuckm/SoftwareSerialIn
Just beginning to to understand with arduino. I plan to put together a small device that accesses the internet at the site, and then, depending on the information that plays a mp3 file. From the annotation of to the Enternet Shield mp3 Shield and read that they both involve the 10-pin, and thus come into conflict. What to do in such a case, or is there an opportunity for playing time off Ethernet Shield and vice versa?
I dont know about your mp3 shield but on the ethernet shield pin 10 is the Slave Select pin.
The MISO, MOSI, and CLK pins can be shered with other shields but not the SS pin.
The only way to solve this would be to cut the connector from the mp3 shiled and connect it to antother pin. Then you will also need to recompile the libs for your mp3 shield to reflect the change of pin.
For further information see Arduino SPI, Arduino Ethernet