BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Trouble programming new board with same code :-(

Hi there,

I’ve now had success in programming a Wemos D1 Mini on my Mac using the Arduino IDE application which is great.

I’ve just purchased an Arduino Nano (https://www.ebay.co.uk/itm/Mini-USB-Arduino-Nano-Compatible-V3-0-ATmega328P-5V-16MHz-SOLDERED-HEADERS/262738901345?ssPageName=STRK%3AMEBIDX%3AIT&var=561685003914&_trksid=p2057872.m2749.l2648) and am now trying to upload the same sketch that I uploaded to the Wemos D1 Mini to the Nano.

As this is a ‘compatible’ Nano I’m not totally sure that I have everything set correctly as it took me forever to figure out I needed the Programmer to be Arduino as ISP instead of AVRIPS mkii which it was originally set to for the D1 Mini and also had to change the Processor to ATmega328P (Old Bootloader) instead of ATmega328P which I had it on for the Wemos D1 Mini.
Even then I’m not totally certain that’s all correct even though it did upload and work?

Just messing with every single possible variant of board, processor and programmer took me forever to even get anything uploaded to it but in the end it did upload a very simple blink sketch which I added in a serial print so I could tell that my sketch was definitely uploaded (it already had a blink sketch on it so placing the serial print message in there let me know for definite that my sketch had uploaded).

Now I’ve just tried uploading the sketch I had on my Wemos D1 Mini to the Nano and I get an error immediately saying :

Blynk_-_Read_Value:9:10: fatal error: ESP8266WiFi.h: No such file or directory
 #include <ESP8266WiFi.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
exit status 1
ESP8266WiFi.h: No such file or directory

The sketch I’m trying to upload is this :

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "My Wifi Name";
char pass[] = "xxxxxxxxxxxxxx";


BlynkTimer timer;

// Setup timer function
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
/*  Serial.println("Checking to see if Blynk is up and running"); */

  if(!Blynk.connected())
  {
    Serial.println("Reconnecting ... ");
    Blynk.connect();
    Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,82), 8080);
  }
}


// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  /*pinValue = map(pinValue, 0, 1023, 0, 127);*/
  Serial.println(pinValue);
  // process received value
}


/* Get and send GPS co-ordinates */
BLYNK_WRITE(V2)
{
  GpsParam gps(param);
  // Print 6 decimal places for Lat
/*  Serial.println(gps.getLat(), 7);
  Serial.println(gps.getLon(), 7);
  Serial.println(gps.getAltitude(), 2);
  Serial.println(gps.getSpeed(), 2);*/

  /* Send GPS Co-ordinates to Blynk to show on map in iPhone App */
  int index = 0;
  float lat = (gps.getLat(), 7);
  float lon = (gps.getLon(), 7);
  Serial.println("LATITUDE = ");
  Serial.println(gps.getLat(), 7);
  Serial.println("LONGITUDE = ");
  Serial.println(gps.getLon(), 7);
  Blynk.virtualWrite(V10, index, gps.getLat(), gps.getLon(), "value");

}


/* Turn LED on and off */
BLYNK_WRITE(V3)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable

  if (pinValue == 1)
    {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Turning LED ON");
    } else
      digitalWrite(LED_BUILTIN, HIGH);
      Serial.println("Turning LED OFF");
}
  


/* Everything in here only runs once */
void setup()
{
  // Set onboard LED
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,82), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}


/* This is our main loop. Everything in here will happen many times */
void loop() 
{
/* ONLY ORIGINAL LINE BELOW */  
  Blynk.run();
/* ONLY ORIGINAL LINE ABOVE */
  timer.run();
}

Does anyone know why this isn’t working? I’m actually going to be creating something completely different for the Nano (hopefully if I can get that to work!) but just wanted to try this sketch first as it works fine on the Wemos D1 Mini so wanted to try it out on the new board to see it all working on it. It won’t upload though so not too sure what I have wrong and where?

Many thanks for any help with this.

Best wishes,

Mark

• Hardware as shown in link above to Amazon :


• Local Blynk server running on OSX. All working fine as already working with Wemos D1 Mini

My first question has to be “why?”. It’s a bit like going from an iPhone back to an old Nokia again.

That won’t work, as they have different processors and the Nano has no m,method of communication with the outside world - no built-in WiFi and no Ethernet port.

I’m fairly certain that this setting is only used when you’re programming other types of chips that don’t have built-in bootloaders. The only time I ever use this setting is when I’m using an Arduino or Nano as a controller to upload code to an ATTiny85 chip.
If you’re having problems with flashing the nano then it’s probably the "processor selection that needs to be changed to “ATMega328P (Old Bootloader)”.

That’s because the WiFi library is designed for the ESP8266 processor, with built-in Wifi, and your Nano has the ATMega328P chip, and no built-in WiFi.

The Nano cannot connect to the internet, and therefore to Blynk, without the addition of some extra hardware. This would normally be an ESP-01 board, which has the same processor on it as your Wemos D1 Mini. It then uses this processor simply as a WiFi modem, in a very clunky crippled sort of way, to give WiFi connectivity.

So, coming back to the original question, Why?. What is your reason for wanting to utilise the Nano rather than the D1 Mini?

Pete.

Eek!!

I must have totally misread which Arduino to purchase as could have sworn that I’d read that the Nano had WiFi. That would definitely explain a few things then!! :frowning:

Darn! Will have to order a different board now. What an absolute idiot I feel like now!

What I’m wanting to make is a MIDI controller so I can have 3 potentiometer sliders to send Dynamics, Expression and Volume data along to my DAW (Logic Pro X).

I’d read that I’d need a Nano to do this though I’ve been reading so many sites since starting on all of this that I very easily probably got completely confuddled!

So I suppose a couple of questions now would be, will I be able to use the Wemos D1 Mini instead to create my MIDI controller and then secondly what kinds of things can I keep the Nano for now? I’m going to keep it as it was so cheap but just wondering how much use it will be to me when it’s so limited?

I do have an ESP-01 which I’m able to programme as that was actually the very first module I purchased to see if I could even get it all working and what got me into all of this in the first place.

If I’m able to do what I need on the Wemos D1 Mini though then I’ll go that route instead obviously.

I’d like to be able to run the controller as USB MIDI to my Mac but if the Wemos D1 Mini can’t do that (one of the other reasons I thought I needed a Nano) then at this point I will definitely settle for using a MIDI connector and cable and then I’ll look at getting a more compatible board (UNO maybe?) that can do everything I need.

Sorry for probably making you spit at the screen when I posted above but as you can very easily now tell I’m very very new to all of this and so obviously going to make a fair few mistakes as I already have! :smiley:

Thanks again for all your help as it is very much appreciated.

Best wishes,

Mark

Okay, if these are going to be connected to an analogue input then using any type of ESP8266 based device, including the D1 Mini, will be a problem, as they only have one analogue input.

The Arduino based boards have more analogue inputs, but the basic ones don’t have WiFi. Some of the later boards do, but I have no experience of using those and they are far less “mainstream” as far as the Blynk community is concerned.

Personally, I’d go down the ESP32 route, as they have many more pins that can be use as Analogue inputs and are very similar to the ESP8266 boards in other respects and get a lot of use here.

It is (in theory) possible to use an analogue multiplexer to add more ports to the ESP8266 based boards, but I wouldn’t go down that route for this project if I were you.

Pete.

Thanks Pete.

A couple more questions in that case if I may?

If for now (going to take time to get a new board sent to me) I just use the one potentiometer just to test this out, will the Wemos D1 Mini work either as USB MIDI or via a MIDI lead?

If so then I’d just like to see if I can get anything working at all, even just one input at this point in time would be nice after all the mistakes I’ve made! Would be nice just to have one or two wins at this point :smiley:

If the Wemos D1 Mini can do what I need then I’ll go down that route for now just to see if I can get it spitting out some MIDI to my computer.

Whilst I’m doing that I can purchase a new board. Sorry for what is probably a very silly question but is an Arduino UNO an ESP32 board as you mentioned? I’d read that the UNO is good to use for MIDI (at least pretty sure I did! Could be me reading too many things again! :-)).

If not the UNO then what board would you suggest?

Basically I’d like to (eventually) have 3 potentiometers attached (may add more down the line and buttons too) and to be able to send the MIDI data via USB MIDI to my Mac. I believe that’s the best option for MID but would definitely settle on a MIDI connector and lead if I have to.

Thanks again for all the help with all of this, it really is very much appreciated.

Best wishes,

Mark

I’ve no idea. My excursions into MIDI were many many moons ago, way before the Arduino was a ‘thing’.

A quick search came up with this though:

No, the UNO us the most basic of Arduino devices, effectively very similar to the Nano you already have, but in a larger form factor.

The thing is that the Nano and UNO may be fine for MIDI stuff, but if you also want top use them with an IoT package such as Blynk then your requirements are considerably different to guys on the MIDI forums who say:

If you want a regular ESP32 Dev board then something like this:


but, as i said, I’ve never tried to do any MIDI stuff with any MCU, so everything I’ve said might be total rubbish!

Pete.

Actually looking online I believe that the Arduino UNO isn’t an ESP32 board (see how confusing I’m making all of this!).

I’ve come across this board on eBay and wondering if it’s the type you’re referring to for this?

I also came across an ESP-32S variant but not sure what the difference is between the one with an S and the one without?

So basically just wondering if that’s the board you were meaning and if so does it have enough analog inputs on it for what I need to do and will it work as a USB MIDI device or will it only work via a MIDI lead and connector.

Many thanks,

Mark

Thanks Pete.

I think I’ll do some serious research as to which board I should be using for MIDI applications first as otherwise I’ll probably end up buying another very light paperweight!! :smiley:

Thanks again for all your help with this. I’m sure I’ll be back soon to ask more questions though so apologies in advance!

Best wishes,

Mark