Ok I need to test this further to be sure, I’ve been changing more things and its possible that I got this wrong, but perhaps someone knows what is going on. This concerns a Wemos D1 with:
OLED SPI (SW, no chip select)
a temp sensor,
two buttons (up/down)
an external LED
a relay. (currently not connected)
This is the layout:
const int SCL_PIN = Dn5; //D5
const int SDA_PIN = Dn6; //D6
const int RES_PIN = Dn1; //D1
const int DC_PIN = Dn2; //D2
const int BUTTON_UP_PIN = Dn4; //D4 the pin that the pushbutton is attached to
const int BUTTON_DO_PIN = Dn8; //D8 the pin that the pushbutton is attached to
const int HEATER_RELAY_PIN = 25; //Dx NOT CONNECTED the pin that the Relay is attached to: LOW LVL TRIGGER (so GRND is ON)
const int HEATER_LED_PIN = Dn7; //D7 the pin that the LED is attached to
const int T_SENSOR_PIN = An0; //A0 ADC !! (only this pin = (A0)
I’ve ‘Dn’ corresponds with ‘D’ on the Wemos board.
THIS WORKS…somewhat, since I have the button up connected to the internal led (and I let that one blink) the up button is virtually pushed.
Hence I’ve tried to remap the UP BUTTON to D0, D7 and (IRC) D3 (or in my the code: Dn0, Dn7, Dn3). In all cases the OLED stop working. Anyone got a clue whats going on?
When you install the ESP8288 core and select Wemos D1 Mini as your board type, the Arduino interpreter knows that D1 = GPIO5, D2 = GPIO4 etc.
I’ve never seen Dn5 used in place of D5, and I’d guess that the Arduino interpreter is unable to make any sense of this.
It’s good programming practice not to use the D numbers in code, as it makes it much more difficult to transfer the code to different boards. Much better to simply use the GPIO numbers (1, 2, 3 etc).
But they’re integers. The Arduino IDE converts D5 to 14 (because D5=GPIO14), but I don’t think it will know what to do with Dn5 when it’s declared as an integer.
Pop a Serial.println(Dn5); in there and see what it comes up with. Anything other than 14 then that’s where your problem lies.
Maybe you’d be better sharing your full code if you want constructive and meaningful feedback, as out of context code snippets don’t make sense to those of us who can’t see the full picture.
well, I would consider that lazy. Like here’s my code: figure it out!. So im trying o pin point the issue (aasigning D7 on the wemos from output to input, but as im still a n00b in this its very hard for me to communicate that properly (in one post) as im not yet accustomed to this forum and what people want to see. Anyway here are the parts that I think are relevant:
declarations:
*/
//define means an effective search and replace with on compilation!
#define ESP_NAME "ESP_RELAY"
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <SimpleTimer.h>
#include <U8g2lib.h>
const char* ssid = "wolph42";
const char* password = "smarlov42";
char auth[] = "bccac3b0cb0d44e4b413273fb0862de1";
static const uint8_t An0 = 0; //analogue in/out
static const uint8_t Dn0 = 16;
static const uint8_t Dn1 = 5; //I2C SCL
static const uint8_t Dn2 = 4; //I2C SDA
static const uint8_t Dn3 = 0; //not analogue
static const uint8_t Dn4 = 2; //LED
static const uint8_t Dn5 = 14; //SPI CLK
static const uint8_t Dn6 = 12; //SPI MISO
static const uint8_t Dn7 = 13; //SPI MOSI
static const uint8_t Dn8 = 15; //SPI CS
static const uint8_t RXn = 3;
static const uint8_t TXn = 1;
// Note that there is no mem difference between const and define, however define is more bug prone!
const int SCL_PIN = Dn5; //D5
const int SDA_PIN = Dn6; //D6
const int RES_PIN = Dn1; //D1
const int DC_PIN = Dn2; //D2
const int BUTTON_UP_PIN = Dn4; //D4 the pin that the pushbutton is attached to
const int BUTTON_DO_PIN = Dn8; //D8 the pin that the pushbutton is attached to
const int HEATER_RELAY_PIN = 25; //Dx NOT CONNECTED the pin that the Relay is attached to: LOW LVL TRIGGER (so GRND is ON)
const int HEATER_LED_PIN = Dn7; //D7 the pin that the LED is attached to
const int T_SENSOR_PIN = An0; //A0 ADC !! (only this pin = (A0)
U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ SCL_PIN, /* data=*/ SDA_PIN, /* cs=*/ U8X8_PIN_NONE, /* dc=*/ DC_PIN, /* reset=*/ RES_PIN);
U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ SCL_PIN, /* data=*/ SDA_PIN, /* cs=*/ U8X8_PIN_NONE, /* dc=*/ DC_PIN, /* reset=*/ RES_PIN);
and in void setup():
pinMode(BUTTON_UP_PIN, INPUT);
pinMode(BUTTON_DO_PIN, INPUT);
pinMode(T_SENSOR_PIN, INPUT);
pinMode(HEATER_LED_PIN, OUTPUT); // currently a led, later this will be replaced with a write to the hub
pinMode(HEATER_RELAY_PIN, OUTPUT); // The actual
I can’t speak for others, but one way I need to use to “troubleshoot others code” is to load the same code on my hardware and test… can’t do that with snippets
Aside from the complication of all your defines (fine for you perhaps, but you are asking for 3rd party assist ) I also see you referencing the OLED config twice, for no apparent reason… so who knows what else you are doing…
well, this is annoying, I’ve simplified my code in the ‘annoying’ area and now I can’t reproduce the issue anymore… you could say case closed, but I have a feeling this will bite me in the future who knows.