Electron and general platform woes :(

This will probably come across a bit bitchy, but it’s not supposed to. I love Particle and I’ve been using them since the 1st batch was shipped, I really want to use them for everything but I have constant problems with either faulty hardware, software/library inconsistencies, undocumented “quirks” or just lack of documentation.

I find it really frustrating, in fact all the projects I have got working have been an epic battle. Recently I’ve started developing projects on Arduino then trying to port to Particle once I’m done to avoid the headaches, which isn’t productive at all.

Anyway this particular project I’m trying to get an Electron to work with the Adafruit ILI9341 TFT resistive touchscreen. After a lot of testing it turns out I have a faulty electron, (support have confirmed this) so I’ve been working with a photon. I have the ILI9341 doodle example working. This involved fixing the libraries and I couldn’t even find a Touchscreen lib, so I ported the Arduino one (I’ll publish this once fully tested).

So I want to port to Electron. I’d assumed that would have been as simple as changing the target device and compiling, but it just doesn’t seem to work. To keep it simple I went for an OTA update via the web IDE. The compile timed out the 1st time, then the second time complained about not being able to find Arduino.h. I tried swapping this for application.h but now it throws up loads of errors, so obviously yI@m still missing all the stuff defined in Arduino.h.

To make it more complicated, sometimes I make changes and recompile and it has no effect on the error, other times I don’t make any changes and I get a different error back.

I tried to compile using Atom, however, this fails to include the mfGFX lib, despite the lib being included in the project properly. I also gave up and manually created the cpp/h files as per the other libs I’ve had to create myself and removed the lib included via shared libs. I still get the same error.

So does anyone have any suggestions on how to get the Adafruit touch demo working on an Electron, if I’m just porting a working version from a Photon?

1 Like

Showing the errors you’re getting would be a great start, especially if it worked on a Photon. Unless you’re using hardware specific features, there’s no reason there should be a noticeable difference (provided other factors are the same, e.g. system version).

If it's a 4 wire touch screen I've ported and partly rewritten one ages ago and works well with this touch display, so I guess it will with yours too.
Particle Web IDE

And we now have 0.6.2-rc.1 which should fix some (most) Arduino compatibility issues.

Web IDE> Photon = No Errors

Web IDE> Electron (after changing “Arduino.h” to “Application.h”)…

TouchScreen.cpp:24:0:
/workspace//src/TouchScreen.h:51:12: error: ‘RwReg’ does not name a type
volatile RwReg *xp_port, *yp_port, *xm_port, *ym_port;
^

/workspace//src/TouchScreen.h:52:3: error: ‘RwReg’ does not name a type
RwReg xp_pin, xm_pin, yp_pin, ym_pin;
^

If I try and compile the same code using Atom, it fails but says “there were no errors”

What system version are you targeting?
0.6.0 or as I already suggested 0.6.2-rc.1 should work better than 0.6.1

Want to check out my lib?

BTW, how did you not find it? Did you not search for touch with lib-search?

C:\Users>particle library search touch
> Found 3 libraries matching touch
captouch 0.0.1 65 Capacitative Touch sensor using just a 10M resistor
Touch_4Wire 0.9.5 [mine] 39 Adafruit 4-Wire-Touchscreen library (Compatible with Core 0.3.4ff, Photon/P1 0.4.3ff)
LightTouch 0.0.2 6 A light-weight [4-wire] Touchscreen library

or

Thanks ScruffeR I’ve replaced my lib with yours and it’s fixed that error, I think the only difference was that I was including Application.h and you’re including Particle.h. I was following instructions from a different post about when Arduino.h doesn’t work. I still don’t get why it works fine on Photon, but not electron but NVM.

I now have an issue that SPI1 isn’t working on electron, but I’ve not checked the docs on that one, so I’m guessing it either doesn’t have the same HW SPI, or maybe it’s just called something different? Again, would it have been that hard to make it the same as the Photon :smiley:

I did search for the touchscreen lib, but I might have included Adafruit in my search terms and that’s why I didn’t find it.

Also I’m targeting 0.6.1 on the photon, but that is compiling fine, I’m targeting whatever the latest version of the Electron is, I updated the firmware a few days ago.

I’m pretty sure it’s meant to be working just the same.

You can check the system version of your Electron with Web IDE or

particle identify

I guess your Electron is still running an old version (or your IDE is targeting the wrong one)
See these closed issues

OK, so the electron is plugged in and on COM8, however “particle identify” returns “serial: unknown error”. If I run the Particle firmware util it says it’s on v6.0 but only give the option of flashing v6.0.

If I put it in DFU mode and do particle update it goes through the motions of updating but it doesn’t list what version it was or what it’s updated to. I’ve done this and checked the web IDE it still says it’s v6.0

So I’m not 100% sure what version it currently is but if I try and compile on the web IDE it’s going to compile for v6.0 which doesn’t seem to let you use SPI1.

It needs to be in listening mode for that command to work, so give that another shot if it wasn’t.

The latest version is currently 0.6.2-rc-1, which has a bunch of library related improvements, thus worthwhile updating.

I'm going to check with my devices

Do you get any errors or does it just not work?

Got it working! I looks like it wasn’t on v6.1 despite having already done the firmware upgrade a week or 2 ago, the web IDE wasn’t updating just logged out, reset the electron and started again.

So, if both devices are on the same firmware version, there should be no difference in the code when switching between Photon <-> Electron? (apart from the Electron specific stuff)

I think this was the source of many issues, combined with the fact that I though I was already on the latest version (not counting RCs).

TBH the community support has been amazing :smiley:

Now I just need to get the desktop IDE compiling so I don’t waste my mobile data. I’ll have a play around and see where I get to.

Random question about the 4wire touch lib… The update rate on electron seems massively slower than the photon running the same code, any ideas?

2 Likes

Just that SPI1 has no methods when you try and call them in the code. It's working now with 6.1 and I haven't changed the code at all.

You'll need to have the CLI for local flashing, since the desktop IDE currently doesn't handle wired flashing as far as I'm aware. If you've got the CLi, hook up your device in DFU mode and issue particle flash --usb firmware.bin from the respective directory. Make sure you've got the DFU drivers installed though.

That's basically what I've been doing but I figured if I'm flashing locally via CLI I might as well use Atom instead of the web IDE as it does have some useful features. I have had this working before just as a test, but the problems I'm having at the moment are just to do with libs not being included properly. I'm gonna start another project from scratch and see where I'm going wrong.

DHL have just rang up and my new Electron will be arriving tomorrow so it's been a productive day today.

2 Likes

Hmm, I'm not sure - it shouldn't be.
The only thing I could imagine is that loop() might be called less frequently due to cellular connection. But if you use SYSTEM_THREAD(ENABLED) that influence should get removed from the equation.


Update:
I tested this with threading enabled and I can't really see any difference in performance between Photon and Electron.

Great, I'll give it a go when I get a chance, I have a replacement Electron now.

I've had a PCB made too, the spec for my project is: as small a package as possible containing an Electron, lipo, touchscreen, wireless charging, haptic feedback and piezo. I made the PCB so that it will accept either the resistive or capacitive TFT and the pinouts are such that it will work with either a Photon or Electron as I realised it might be useful for others.

I'm going to design a 3D printable case too so I might start a thread about it see if anyone else is interested. The end result is a kind of no-fuss / super easy to use smartphone. You could write the firmware to make it do whatever you like.

When using an Electron with a display, one thing to check before finishing your PCB is whether your display would run off the 3.7V provided by the Electron’s Vin pin when you only run on battery.

You might need a buck boost converter then - unless you have other means to power the setup.

Yes it runs fine off 3.3v - 5v

Just a bit of an update on this and it’s just more of the same. I don’t get why I seem to have so many problems with this platform.

The PCBs have arrived and I’m just building a test rig using headers so I can interchange parts.

I had the circuit up and running on a breadboard fine, swapped it over to PCB and it doesn’t work. It’s actually a very simple PCB and really just connects the Particle to the TFT breakout. So I checked all the pin connections with the devices in situ with a meter and everything is as it should be.

I spent some time diagnosing the issue and after an hour or 2 I got it working but essentially nothing had changed. The issue seemed to be intermittent SPI. At some point between trying 2 different Photons and 2 different Electrons, it just started working.

For some reason, half way through one of the Photons started flashing blue. This morning I’ve come to look at it and after re-adding it I now get flashing cyan, then red. So looked up other people with the same issue and it looks like corrupt keys.

So following the instructions to generate/add new keys and the last step… “particle keys send photon.pub.pem” returns the error… “Please provide a filename for your device’s public key ending in .pub.pem” The file is there, I used tab to auto-complete it. so once again I’m at a dead end.

I just don’t get why everything seems to require so much effort. I love a challenge and I’m sure I’ll get there in the end, but sometimes I just want to crack on and work on the solution I’m trying to make and it feels like I spend 90% of my time debugging issues with the platform rather than the app I’m trying to make. Yesterday when I was trying to debug the PCB/SPI issues. 50% of the time I was swapping photons, or resetting them, or adding them because they weren’t connecting to WiFi.

Would love to see the GERBER screenshots for the top and bottom copper layer if that’s shareable.

I would simply switch back to the breadboard setup with the same photon and see if everything works fine. If that’s working fine, there’s probably more to look into for the PCB design.