These are chat archives for esp8266/Arduino

15th
Jan 2016
fmgomes
@fmgomes
Jan 15 2016 01:21
Hi, do you know if GPIO16 can be used for I2C?
I am using an ESP-12 and am trying to use GPIO16 as one of the I2C pins by calling Wire.pins(16, 2), but this is not working, and using the I2C scanner it doesn't detect any I2C peripheral connected
fmgomes
@fmgomes
Jan 15 2016 01:36
I've confirmed it, I can't use GPIO16 to I2C :-)
Stavros Korokithakis
@skorokithakis
Jan 15 2016 01:39
has anyone connected the ESP to a cellular modem
?
or know of a modem i could connect it to
mkokotovich
@mkokotovich
Jan 15 2016 01:59
I'm using esp with arduino ide to control my Philips hue lights. Using WifiClient to open a connection to the bridge and write a PUT request. When I trigger the command, the lights respond almost instantly (so the json payload must have been received almost instantly, which is the last thing to be written). However, there is then a 3-5 second delay before that last println returns. Any ideas what could be causing the delay?
Martin Ayotte
@martinayotte
Jan 15 2016 02:31
@fmgomes , why are you using GPIO16,GPIO2 instead of GPIO0,GPIO2 for I2C ? Did you provide pullups to SDA/SCL ?
Aditya Tannu
@AdySan
Jan 15 2016 05:39
@skorokithakis theres a few variants of the SIM800 and SIM900 boards on Ali, I've been thinking of getting one. One of those has GSM and GPS on the same board
@skorokithakis they're basically cheaper clones of Adafruit Fona
Johan Euphrosine
@proppy
Jan 15 2016 08:45
@skorokithakis I think that's the SIM808 that support GSM and GPS
it would be awesome to find a way to bridge the wifi and gprs traffic thru lwip.
beikeland
@beikeland
Jan 15 2016 09:14
kinda OT; but if you wanna do celluar stuff; https://www.particle.io/cellular might be intersting. Especially if you want cheap low volume data. I tink its $2-3/month for 2MB or something
Johan Euphrosine
@proppy
Jan 15 2016 09:15
I had good result with http://neo.aeris.com/ too :)
beikeland
@beikeland
Jan 15 2016 09:15
i backed the kickstarer project and shoud be getting mine soon-ish
Johan Euphrosine
@proppy
Jan 15 2016 09:15
@beikeland lucky you :)
I heard the wio-link are shipping soon too,
I tested esp8266/arduino on it, works out of the box with the nodemcu board def
but the pinout is a bit weird
fmgomes
@fmgomes
Jan 15 2016 10:50
@martinayotte , regarding the usage of GPIO16 for I2C, I was trying to add I2C support (an OLED display) to an existing circuit that was already using GPIO2, so I have tried with GPIO0 and GPIO16, providing a pull-up on GPIO16, but the I2C scanner returned no available I2C devices. I changed the circuit to the 'usual' GPIO0 and GPIO2 and it worked immediately, so I transfered the function I had on GPIO2 (was a SPI CS), to GPIO16 and now everything works :-)
Unfortunately I don't have any pins available to add now some keys, perhaps I will add a port expander on I2C
ystrem
@ystrem
Jan 15 2016 11:23
@fmgomes What do you build ?
fmgomes
@fmgomes
Jan 15 2016 12:16
@ystrem I'm building a webradio, with a VS1053 as a codec. The VS1053 uses SPI, but needs additionally a RST signal, plus 2 chip select pins, one for audio data and other for control, so it uses a lot of the ESP8266 pins. I've now added an I2C OLED display, it is still missing some input method (keys, rotary encoder, etc.) but I only have the analog input pin available :-) I could use some keys in a resistor ladder to have an analog input value depending on the key pressed, or I could use the Tx/Rx pins, but need to add some 'logic circuitry' to be able to still use them for programming the ESP8266 and to use the keys. Or could add an I2C port expander to have some extra I/O pins.
Helio Machado
@0x2b3bfa0
Jan 15 2016 12:20
@all-the-c++-savvy-people-here: I'm tryng to implement a json config parser on a separate file, but I don't know how. Here you can see the files:

config.c

#include <ArduinoJson.h>
#include <FS.h>

#include "config.h"


File configFile;
std::unique_ptr<char[]> buf(new char[size]);
StaticJsonBuffer<200> jsonBuffer;
JsonObject& json;


int Config::load(String file = "/config.json") {
  if(!filename.startsWith("/")) filename = '/' + filename;

  SPIFFS.begin();

  configFile = SPIFFS.open(filename, "rw");
  if (!configFile) return 1;

  size_t size = configFile.size();
  if (size > 1024) return 2;

  configFile.readBytes(buf.get(), size);
  json = jsonBuffer.parseObject(buf.get());
  if (!json.success()) return 3;
  return 0;
}


int Config::save() {
  if (!configFile) return 1;
  json.printTo(configFile);
  return 0;
}

config.h

class Config {
  public:
    int load();
    int save();
    JsonObject& json;
  private:
    File configFile;
    std::unique_ptr<char[]> buf(new char[size]);
    StaticJsonBuffer<200> jsonBuffer;
};
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:04
This message was deleted
This message was deleted
Me No Dev
@me-no-dev
Jan 15 2016 13:06
I see a few things
there maybe more
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:07
@me-no-dev: :crystal_ball: ?
Me No Dev
@me-no-dev
Jan 15 2016 13:07
File configFile;
std::unique_ptr<char[]> buf(new char[size]);
StaticJsonBuffer<200> jsonBuffer;
JsonObject& json;
Those are global defined like that in the cpp
std::unique_ptr<char[]> buf(new char[size]);
Can't use new in the header
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:08
@me-no-dev: I'm new to C++
Me No Dev
@me-no-dev
Jan 15 2016 13:08
new should go into tne constructor
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:08
Should I define things only as public/private on the header?
Me No Dev
@me-no-dev
Jan 15 2016 13:08
and should be freed in the deconstructor
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:09
@me-no-dev: Sorry for abusing your patience that way: what is a constructor/deconstructor? Also, where should I put these variable definitions?
Me No Dev
@me-no-dev
Jan 15 2016 13:11

like

char *buf;

in the header then

buf = new char[size];

in Config(){}
then

if(buf != NULL) delete buf;
in ~Config(){}
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:12
@me-no-dev: aah!
Me No Dev
@me-no-dev
Jan 15 2016 13:15
you do not need to put the variables in the CPP file since they are defined in the header
you just use them :) they are there
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:16
@me-no-dev: Why 'JsonObject' does not name a type?
Me No Dev
@me-no-dev
Jan 15 2016 13:17
because you did not include ArduinoJson.h in the header
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:20
@me-no-dev: Ok :worried:
@me-no-dev: Why now I have these errors?
Oh no...
[Fri Jan 15 14:23:07 2016] Processing esp01_1m (platform: espressif, upload_resetmethod: nodemcu, board: esp01_1m, framework: arduino)
--------------------------------------------------------------------------------
xtensa-lx106-elf-gcc -o .pioenvs/esp01_1m/src/config.o -c -std=gnu99 -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -Os -mlongcalls -mtext-section-literals -falign-functions=4 -U__STRICT_ANSI__ -ffunction-sections -fdata-sections -MMD -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01 -DARDUINO=200 -DPLATFORMIO=020702 -I/home/casa/.platformio/packages/framework-arduinoespressif/tools/sdk/include -I.pioenvs/esp01_1m/FrameworkArduino -I.pioenvs/esp01_1m/FrameworkArduinoVariant -I.pioenvs/esp01_1m/Json_ID64 -I.pioenvs/esp01_1m/ESP8266WiFi -I.pioenvs/esp01_1m/ESP8266mDNS -I.pioenvs/esp01_1m/ESP8266WebServer -I.pioenvs/esp01_1m/DNSServer -I.pioenvs/esp01_1m/EEPROM src/config.c
In file included from .pioenvs/esp01_1m/FrameworkArduino/Print.h:27:0,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/../Arduino/Print.hpp:31,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/DummyPrint.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/JsonPrintable.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonVariant.hpp:13,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonBuffer.hpp:15,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/BlockJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/DynamicJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson.h:8,
from .pioenvs/esp01_1m/Json_ID64/ArduinoJson.h:14,
from src/config.h:1,
from src/config.c:1:
.pioenvs/esp01_1m/FrameworkArduino/Printable.h:25:1: error: unknown type name 'class'
class Print;
^
.pioenvs/esp01_1m/FrameworkArduino/Printable.h:33:1: error: unknown type name 'class'
class Printable {
^
.pioenvs/esp01_1m/FrameworkArduino/Printable.h:33:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
class Printable {
^
In file included from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/../Arduino/Print.hpp:31:0,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/DummyPrint.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/JsonPrintable.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonVariant.hpp:13,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonBuffer.hpp:15,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/BlockJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/DynamicJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson.h:8,
from .pioenvs/esp01_1m/Json_ID64/ArduinoJson.h:14,
from src/config.h:1,
from src/config.c:1:
.pioenvs/esp01_1m/FrameworkArduino/Print.h:34:1: error: unknown type name 'class'
class Print {
^
.pioenvs/esp01_1m/FrameworkArduino/Print.h:34:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
class Print {
^
In file included from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/JsonPrintable.hpp:10:0,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonVariant.hpp:13,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../JsonBuffer.hpp:15,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/BlockJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/DynamicJsonBuffer.hpp:10,
from .pioenvs/esp01_1m/Json_ID64/include/ArduinoJson.h:8,
from .pioenvs/esp01_1m/Json_ID64/ArduinoJson.h:14,
from src/config.h:1,
from src/config.c:1:
.pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/DummyPrint.hpp:12:1: error: unknown type name 'namespace'
namespace ArduinoJson {
^
.pioenvs/esp01_1m/Json_ID64/include/ArduinoJson/Internals/../Internals/DummyPrint.hp
Is my culprit?
Me No Dev
@me-no-dev
Jan 15 2016 13:25
include Arduino.h before ArduinJson.h in the header
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:26
@me-no-dev: Then:
.pioenvs/esp01_1m/FrameworkArduino/FS.h:25:18: fatal error: memory: No such file or directory
#include
Maybe shoud I include some 8266 specific header?
Me No Dev
@me-no-dev
Jan 15 2016 13:28
btw... do you have
#ifndef _MY_CONFIG_H_
#define _MY_CONFIG_H_
#include "Arduino.h"
#include "ArduinoJson.h"

class Config .....

#endif
and by the way I have never ever seen errors like yours
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:29
@me-no-dev: Yes, I have it.
My errors are really a record :smile:
@me-no-dev: Maybe that I'm using plain C++ w/o arduino preprocessor?
Me No Dev
@me-no-dev
Jan 15 2016 13:30
?
you not using this project's source?
you should have started with that :D
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:32
@me-no-dev: I'm using ESP8266Arduino on PlatformIO. The only mischief I've done is to rename luz.ino (the main code block) to main.cpp
And I've done that because Ivan suggested me this (as workaround for a preprocessor bug)
Chris Elsworth
@celsworth
Jan 15 2016 13:33
its using gcc not g++ ?
oh platform espressif, thats native sdk.
Me No Dev
@me-no-dev
Jan 15 2016 13:33
yeah... I have no clue what's going on there... not a platformio user
Chris Elsworth
@celsworth
Jan 15 2016 13:33
you can't use ArduinoJson (C++) with that
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:33
@celsworth Why?
Chris Elsworth
@celsworth
Jan 15 2016 13:33
it's an Arduino library and you have none of the supporting Arduino-core code for it
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:34
@celsworth: But, I'm using the Arduino framework.
Chris Elsworth
@celsworth
Jan 15 2016 13:34
no you're not?
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:34
Only without the ino/pde preprocessor
Chris Elsworth
@celsworth
Jan 15 2016 13:34
platform: espressif from your paste above
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:35
[env:esp01_1m]
platform = espressif
framework = arduino
board = esp01_1m
upload_resetmethod=nodemcu
Chris Elsworth
@celsworth
Jan 15 2016 13:35
that's compiling it as C not C++ for starters
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:35
@celsworth @me-no-dev: It says that the framework is Arduino...
Chris Elsworth
@celsworth
Jan 15 2016 13:36
true, it does. but its still compiling it as C. xtensa-lx106-elf-gcc
it needs to use xtensa-lx106-elf-g++
Me No Dev
@me-no-dev
Jan 15 2016 13:36
yeah, you have access to the files but you are not compiling them as C++
Chris Elsworth
@celsworth
Jan 15 2016 13:36
probably want to ask ivan
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:36
@celsworth: Ok, calling...
@ivankravets: Ping
@celsworth @me-no-dev: Thank you very much for your patience! I should begin with that!
Chris Elsworth
@celsworth
Jan 15 2016 13:38
oh its because its config.c
try calling it config.cpp
red herring about the espressif platform, sorry
I had to scroll right to see the filename in the compile command paste ;)
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:40
@celsworth: Ok, that solves the odd issue :) I'm very silly! I ever thought that all was cpp!
Chris Elsworth
@celsworth
Jan 15 2016 13:41
I didn't see it for a while ;)
Ivan Kravets
@ivankravets
Jan 15 2016 13:42
@crushedice2000 You can't use C++ stuff in *.c files
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:42
@ivankravets Yes, I know with extern "C++", but I thought that it was a cpp.
Chris Elsworth
@celsworth
Jan 15 2016 13:43
@ivankravets yeah spotted it eventually
Me No Dev
@me-no-dev
Jan 15 2016 13:43
extern is to use C stuff inside CPP files
Ivan Kravets
@ivankravets
Jan 15 2016 13:43
@celsworth Sorry for wrong ping :)
Chris Elsworth
@celsworth
Jan 15 2016 13:43
;)
Ivan Kravets
@ivankravets
Jan 15 2016 13:43
@crushedice2000 do you need any help as for PlatformIO?
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:44
@ivankravets: No, it seems to be my error. PIO behaves very well ;)
Ivan Kravets
@ivankravets
Jan 15 2016 13:44
@crushedice2000 :)
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:51
(@me-no-dev || @celsworth ): Why
Config::Config() {}

Config::~Config() {
  if(buf != NULL) delete buf;
}
returns
src/config.cpp:3:16: error: definition of implicitly-declared 'Config::Config()'
Config::Config() {}
^
src/config.cpp:5:17: error: definition of implicitly-declared 'Config::~Config()'
Config::~Config() {
^
Me No Dev
@me-no-dev
Jan 15 2016 13:52
you did not define then in the header in the class?
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:52
@me-no-dev: How?
Me No Dev
@me-no-dev
Jan 15 2016 13:53
#ifndef _MY_CONFIG_H_
#define _MY_CONFIG_H_
#include "Arduino.h"
#include "ArduinoJson.h"

class Config {
  public:
    Config();
    ~Config();
    ......
};

#endif
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:55
@me-no-dev: Nevermind, I thought that it was automagically declared. I'll need a :mag: and a :crystal_ball: soon!
@me-no-dev: uninitialized reference member 'Config::json' [-fpermissive] means that I should initialize it on the base of the cpp?
Me No Dev
@me-no-dev
Jan 15 2016 13:58
should be initialized in the constructor
Helio Machado
@0x2b3bfa0
Jan 15 2016 13:58
@me-no-dev: I won't know the size of that until load() is called
#ifndef _MY_CONFIG_H_
#define _MY_CONFIG_H_

#include <Arduino.h>

#include <ArduinoJson.h>
#include <FS.h>

class Config {
  public:
    Config();
    ~Config();
    int load(String filename = "/config.json");
    int save();
    JsonObject& json;
  private:
    File configFile;
    char *buf;
    StaticJsonBuffer<200> jsonBuffer;
};

#endif
#include "config.h"

Config::Config() {}

Config::~Config() {
  if(buf != NULL) delete buf;
}

int Config::load(String filename) {
  if(!filename.startsWith("/")) filename = '/' + filename;

  SPIFFS.begin();

  configFile = SPIFFS.open(filename, "rw");
  if (!configFile) return 1;

  size_t size = configFile.size();
  if (size > 1024) return 2;

  buf = new char[size];

  configFile.readBytes(buf.get(), size);
  json = jsonBuffer.parseObject(buf.get());
  if (!json.success()) return 3;
  return 0;
}


int Config::save() {
  if (!configFile) return 1;
  json.printTo(configFile);
  return 0;
}
Me No Dev
@me-no-dev
Jan 15 2016 14:01
try
Config::Config():json(NULL) {}
also in the load method, if you happen to call load more than once on the same instance of the Config class, you will leak a buf
and you will call SPIFFS.begin() again
Helio Machado
@0x2b3bfa0
Jan 15 2016 14:03
@me-no-dev:
src/config.cpp: At global scope:
src/config.cpp:9:1: error: redefinition of 'Config::Config()'
Config::Config():json(NULL) {}
@me-no-dev: Is bad to begin SPIFSS two times?
Me No Dev
@me-no-dev
Jan 15 2016 14:03
did you put the whole thing again or just added json(NULL) to the constructor you already had up in the file?
Helio Machado
@0x2b3bfa0
Jan 15 2016 14:04
@me-no-dev : whole thing.
Me No Dev
@me-no-dev
Jan 15 2016 14:04
yeah....
:D
remove one of them
Helio Machado
@0x2b3bfa0
Jan 15 2016 14:04
@me-no-dev:
src/config.cpp: In constructor 'Config::Config()':
src/config.cpp:7:27: error: invalid initialization of non-const reference of type 'ArduinoJson::JsonObject&' from an rvalue of type 'int'
Config::Config():json(NULL) {}
^
Me No Dev
@me-no-dev
Jan 15 2016 14:05
and I have not read the FS fies recently to answer the other question, but if not taken care of in the class, you should not call it twice
yeah, not much experience with ArduinoJson as well
I know @sticilface used it for some projects
Helio Machado
@0x2b3bfa0
Jan 15 2016 14:07
This message was deleted
Me No Dev
@me-no-dev
Jan 15 2016 14:07
maybe you should have json(JsonObject())
or something like it
Stavros Korokithakis
@skorokithakis
Jan 15 2016 14:43
do you guys know what those weird two-level ESP breakouts do?
i just got one
Chris Elsworth
@celsworth
Jan 15 2016 14:55
link?
if its the one I'm remembering it just moves the usb onto another board so you can detach it for production use, maybe
Stavros Korokithakis
@skorokithakis
Jan 15 2016 14:56
yeah, but it has a LED and a LDR
Chris Elsworth
@celsworth
Jan 15 2016 14:57
hard to tell but I'll bet they're just hooked up to some gpio or other for testing with
its a dev board after all, not unusual for dev boards to have things on to play with
Stavros Korokithakis
@skorokithakis
Jan 15 2016 14:58
yeah, someone posted about it, looks like they just have these things hooked up to GPIOs
looks fun, not super useful, but it's nice for a demo or something
on the top level, it has an AMS1117 regulator
bottom level has a serial programmer and two smaller regs
two caps and four resistors top too
(i love how i can tell what boards have just by looking now)
(it used to be "some crap")
by the way, looks like the bottom board is pretty much a handy FTDI programmer
i can probably connect one of my tiny breakouts and it'll flash with no change
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:45

@me-no-dev: I'm finally getting something good, however, I would like to call a function to populate the JsonObject and then use it from setup().

main.cpp:

#include "main.h"

bool config() {
  // StaticJsonBuffer<200> jsonBuffer;
  configFile = SPIFFS.open("/config.json", "r");
  size_t size = configFile.size();
  std::unique_ptr<char[]> buf(new char[size]);
  configFile.readBytes(buf.get(), size);
  json = jsonBuffer.parseObject(buf.get());
}

void setup() {
  SPIFFS.begin();
  Serial.begin(115200);
  config();
 Serial.println( json["essid"]);
}

main.h:

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
// #include <WiFiUdp.h>
// #include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <DNSServer.h>
#include <EEPROM.h>
#include <FS.h>

bool config();

StaticJsonBuffer<200> jsonBuffer;
File configFile;
JsonObject& json = jsonBuffer.createObject();
However I can't do that because I can't change the json variable once defined ¿why?
Me No Dev
@me-no-dev
Jan 15 2016 15:47
your "json" is global in this state
no need to initialize it
before it was a class member, now it's global
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:48
@me-no-dev: I want to access it from outside config() after it runs.
Me No Dev
@me-no-dev
Jan 15 2016 15:49
just have JsonObject& json;
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:50
@me-no-dev
src/main.h:20:13: error: 'json' declared as reference but not initialized
JsonObject& json;
Why?
Me No Dev
@me-no-dev
Jan 15 2016 15:50
it should be just JsonObject json;
the & is for when passing as argument
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:51
@me-no-dev
src/main.h:20:12: error: no matching function for call to 'ArduinoJson::JsonObject::JsonObject()'
JsonObject json;
Me No Dev
@me-no-dev
Jan 15 2016 15:52
please do not make me read the Json library now :D
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:53
@me-no-dev: I don't want to make you to read that :smile:
Is there any obvious solution?
Or should I change my workflow?
@me-no-dev: Maybe should I discuss that with the ArduinoJson guys?
This is getting a bit off-topic and I don't want to overload you with non-8266 questions.
Now I'll go offline, later I'll ask they.
Me No Dev
@me-no-dev
Jan 15 2016 15:55
JsonObject json(NULL);
expects a buffer as argument
Helio Machado
@0x2b3bfa0
Jan 15 2016 15:56
@me-no-dev:
src/main.cpp:9:8: error: use of deleted function 'ArduinoJson::JsonObject& ArduinoJson::JsonObject::operator=(const ArduinoJson::JsonObject&)'

No way.
Thank you very much for your patience, I'll stop asking you. Your interest honours you, however I think that the better solution will be to ask the ArduinoJson team.

Thank you very much!

And sorry, I shouldn't do that. You're a 8266 dev.
Have a nice day!
Me No Dev
@me-no-dev
Jan 15 2016 15:59
// A dictionary of JsonVariant indexed by string (char*)
//
// The constructor is private, instances must be created via
// JsonBuffer::createObject() or JsonBuffer::parseObject().
// A JsonObject can be serialized to a JSON string via JsonObject::printTo().
// It can also be deserialized from a JSON string via JsonBuffer::parseObject().
last attempt :)
JsonObject json(JsonBuffer::createObject());
and no I'm not 8266 dev
i'm no dev :D
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:09
@me-no-dev
error: cannot call member function 'ArduinoJson::JsonObject& ArduinoJson::JsonBuffer::createObject()' without object
No way. This is really strange.
Thank you for your efforts!
Me No Dev
@me-no-dev
Jan 15 2016 16:10
really the correct way forward is to use reference to the object in memory (JsonObject *json;) but this library looks too weird for me :) so I need to invest more time to figure it out ;)
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:11
And the only thing you have of non-developer is the nick!
Me No Dev
@me-no-dev
Jan 15 2016 16:11
i'll actually use that time to write a new library, because that one is no good for some really large jsons that we encounter in our esp8266 life
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:11
@me-no-dev: Will be easy for both to ask the ArduinoJson developer.
Me No Dev
@me-no-dev
Jan 15 2016 16:11
it's been brewing in my mind for a while
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:12
@me-no-dev: Reinventing the wheel? Huh!
I should try that before!
Me No Dev
@me-no-dev
Jan 15 2016 16:12
no, just different approach towards the Json objects
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:12
@me-no-dev: Now going offline. See you soon!
Me No Dev
@me-no-dev
Jan 15 2016 16:12
have fun
Helio Machado
@0x2b3bfa0
Jan 15 2016 16:13
@me-no-dev: Would be great to have a good 8266json library. I could give you later some proposals ;)
nanobyte84
@nanobyte84
Jan 15 2016 16:57
Hi - I have trouble using the GPIO16 … do I somhow have to set a special function register since it is the same pin as XPD?
sticilface
@sticilface
Jan 15 2016 17:07
@crushedice2000 it is not bad to start spiffs two times. Ivan has said he'll implement a bool operator similar to file, but it's ok to call it multiple times.
I've been using arduinojson a fair amount.
Me No Dev
@me-no-dev
Jan 15 2016 17:10
@nanobyte84 how are you trying to use it currently? digitalRead() and digitalWrite() work for it
sticilface
@sticilface
Jan 15 2016 17:14
@crushedice2000 I've done what your asking for. I load stuff from a config file into json. And I've also written functions that take arduinojson. But I'm not so sure what you exact problem is.. Did you get it working. My only comment and this is from my phone is that staticjsonbuffer does not play so nice on esp8266. You're adviced to do dynamic...works a lot better.
Doesn't crash so much!
Helio Machado
@0x2b3bfa0
Jan 15 2016 17:49

@sticilface: I'm here again. Sorry, I was offline. Can you provide me some example functions?

I try to save/load a bunch of variables. SSID, PSK, mode, channel, etc.

Helio Machado
@0x2b3bfa0
Jan 15 2016 17:56
Also, what do you mean with doesn't crash so much?
I'm searching a 150% safe solution.
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:04
@sticilface: Are you also saving the lamp brightness on json, as I deduced from reading bblanchon/ArduinoJson#193 That is what I want!
sticilface
@sticilface
Jan 15 2016 18:44
@crushedice2000 I'm saving everything in json;)
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:44
@sticilface: Good practice!
If I need to choose any language for data storage, it's json!
sticilface
@sticilface
Jan 15 2016 18:45
yes.... except it all falls to pieces with arduinojson, and the fact the whole file MUST be in RAM
so i've written / am writing a rather complex ws2812 effects with each one having different parameters... brightness, speed, text, colour1..2 etc etc.. so i've got it where each effect saves it own presets to an arduino json file, and then loads the available presets back when it is switched on. this is fine... but above about 40 effects, the json file hit 5-6k.. so now you have to malloc that.. not so good...
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:49
@sticilface: Isn't https://github.com/interactive-matter/aJson better?
Or another one?
sticilface
@sticilface
Jan 15 2016 18:49
if you want examples of what i do check this lib out https://github.com/sticilface/ESPmanager
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:50
@sticilface : Thanks! Checking!
sticilface
@sticilface
Jan 15 2016 18:50
i started work with this one, and have kinda stuck with it... i think i ran into some other issues with ajson
Load settings and savesettings are the functions your after, line 177 in the cpp
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:53
@sticilface: They seem good...
sticilface
@sticilface
Jan 15 2016 18:54
@me-no-dev I was thinking that it might be possible to write a 'version' of arduinojson, that uses SPIFFS file location as the index for the data... i don't really know how it works under the hood.. but the jsonbuffer, must just store indexes to where in the array things start, stop, type etc.. so spiffs file could be used in that way with seek etc... (just brainstorming)
Helio Machado
@0x2b3bfa0
Jan 15 2016 18:56
@sticilface: It seems a good idea! Do you have a :crystal_ball: at home? This could be implemented (or I think so) ;)
sticilface
@sticilface
Jan 15 2016 19:02
if i had one of those i would spend more time enjoying my blinking lights, than trying to work out why they are crashing!
Helio Machado
@0x2b3bfa0
Jan 15 2016 19:02
@sticilface: cat
Helio Machado
@0x2b3bfa0
Jan 15 2016 19:35
This message was deleted
@/all: Anyone knows why I can't open a SPIFFS file for writing?
Helio Machado
@0x2b3bfa0
Jan 15 2016 19:43
configFile = SPIFFS.open("/config.json", "w");
if (!configFile) {
  Serial.println("Failed to open config file for writing");
  return false;
}
The message triggers.
I can open the same file for "w"
Helio Machado
@0x2b3bfa0
Jan 15 2016 20:10
Good night!