發表文章

目前顯示的是 2月, 2018的文章

Why we should not use the String object of arduino??

When using sd lib, I ran into problem of con char* and string problem in sd.println(), the compiler told me it's not right to write a string.... I have a function which assemble some strings and return back a string. let say String form-string(void); then I tried     myFile = SD.open("test.txt", FILE_WRITE);   // if the file opened okay, write to it:   if (myFile) {     Serial.print("Writing to test.txt...");    myFile.println(form_string());     // close the file:    myFile.close(); The error is that it says it need "const char *" not a "string"... I was so so confused.... I need to go deeper in the string and char array....google it.... turns out that lot of people talk about not to using arduino String objects, saying it's bad, and wast more time and space....well, today we can have powerful and big MCU then before with same cost, I don't really think this is a problem...Until I read this article.... The is the on

2018/2/22..Webserver, EEPROM,SD on ESP..

Passing few days in Kaushong lib, I managed to get some very slow progress in my porgramming; 1. Webserver I have first took a example on esp32 with BME280, work note: http://ldsrc.blogspot.tw/2018/02/esp32-web-server-http-learning-with.html and fall into trouble with bme280 lib for esp32, since the adafruit lib is for it's own board, so there is no way to assigned IIC pins. With my heltec wemos esp32 boards, I do need this function to assigned the IIC pins to cowork with other device. After alomost one day of work, I found out that the example use an modified lib of adafruit for BME280, which is able to assign pins. As to web server, I have to attack the knowage of HTML from zero, there are several stuff on html, after some basic knowage, I took the lib from bbx10 to modify it, so that I can show data, base on some parameter to change the html page,get input (i.e. device_ID), and possible to save it to EEPROM. The web server lib is working on both 8266 and 32. the wifi lib

ESP32 and EEPROM()

There is a library of EEPROM in arduino esp32, and the usage seems very easy and similar to arduino one. and the size of eeprom can be defined at begin: EEPROM.begin(EEPROM_SIZE) and can be written with following, i is address, the 2nd one is the contain, which has a type of Byte EEPROM.write(i,0x00) EEPROM.commit(); for reading: EEPROM.read(i) pretty easy....But you need to have  EEPROM.commit(); at the end otherwise nothing is saving into flash now need to carefully calculate the data I need to write in. device Nr = byte softAP SSID and PSWD, let say 10 char each Need to figure out how to arrange char string and byte array... I need to get string of SSID and PSWD to byte[] array. and will need to get byte[] array back to string

Writing csv formant to SD card on esp8266

It seems that the lib for SD card for 8266 and 32 are not competable....not even SPI lib... and 8266 lib can't assign frequency like in esp32...then it could trouble some to get the spi lib to work with other spi device...may not...if we can setup frequency every time before we write. this could be wrong info from google, there is  boolean SDClass::begin ( uint8_t csPin, uint32_t speed) with the demo of D1 mini of cd card: https://github.com/wemos/D1_mini_Examples/blob/master/examples/04.Shields/Micro_SD_Shield/Datalogger/Datalogger.ino  and others... the pin connection is as following: * The WeMos Micro SD Shield uses: * D5, D6, D7, D8, 3V3 and G * * The shield uses SPI bus pins: * D5 = CLK * D6 = MISO * D7 = MOSI * D8 = CS * * The SD card library uses 8.3 format filenames and is case-insensitive. I first test with cardinfo, and then read and write to make sure that wiring is correct. I wish to make few functions in the web server, such as: 1.

SD card on ESP32 with radiohead

I was trying to work out the sd card on heltec lora board together with lora and GPS. The device need to: 1. get geo info from GPS. 2. Send out through lora. 3. record in sd card. I have done the 1 and 2, but blocked on 3. since sd and lora both use spi interface. I was not so familiar with SPI interface, nor how sw lib was written. It took me a while to make sd card read write works on heltec board. https://ldsrc.blogspot.tw/2018/02/micro-sd-card-for-esp32.html Now, how to make both work? I think I have solved the questions on pins: SPI   SCK     MISO    MOSI      CS Lora   05          19          27         18    (with reset at 14) SD      05          19          27         21 when I tested SD, I pull up 18 to high, to make lora unselected, so that they stay tri state on MISO....this works both on hard wired, or using digital write. I start to search on how to make 2 spi devices works together on a same bus. Here is a very good example here: https://www.circuitsa

ESP32 web server HTTP learning with BME280

圖片
I need a web server on esp32/8266 to work as user interface for config wifi(mode, ssid, pwd) as well we some parameter useful for program usage, and then store it in flash of the chip. I used to use PyBBIO web server on bone or pi, without knowing the basic. Now I have to go into it and find a good one on esp. I have look into the lib of esp32 arduino, there is a simple wifiserver, but too simple and I lack of HTTP knowage. Here is very good one: https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/basic-web-server/ and for ESP32 webserver,Then I found this: so he used a library called  https://github.com/bbx10/WebServer_tng  , which works on 8266 and ESP32, and he also has a sd webserver, seems reallly interesting https://github.com/bbx10/WebServer_tng/blob/master/examples/SDWebServer/SDWebServer.ino I tried his example,  http://educ8s.tv/wp-content/uploads/2017/11/ESP32-Web-Server.zip it did not compile, and come with an error on  no mat

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

圖片
I have purchased 2 micro SD card holder for my esp project. First I would like to test with heltec esp32 lora oled module. this module uses: sck=05 MISO=19 MOSI=27 SS(lora)=18, then I assigned 21 for sd SS and there is a lib in esp32-arduino, which use SS default at 5 I took the example and use SD.begin(21), but I alway get the error: entry 0x40078a9c Card Mount Failed But I do saw once that it read out the sd card type and volume. Not sure it's the issue of lora sd card swithing, or it just can't work. The other esp32 card I have is an wemos esp32 oled, it did not leave me too much pins, I need to find out how to connect sd to it. But I have wemos D1 mini esp8266 on hand, and connect it as:  * The WeMos Micro SD Shield uses:  * D5, D6, D7, D8, 3V3 and G  *  * The shield uses SPI bus pins:  * D5 = CLK  * D6 = MISO  * D7 = MOSI  * D8 = CS It's not working with the example in the arduino IDE 1.8.5, which marked SD(esp8266), but it w