Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple ESP modules and sensors #147

Merged
merged 12 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 27 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,67 +34,52 @@ ESP32 Based GPS Navigator (LVGL - LovyanGFX).

## Specifications

For the moment Icenav works with the next hardware setup and specs **Highly recommended an ESP32 with PSRAM** :
Currently, IceNav works with the following hardware setups and specs

### Customboard ESP32 setup

* ESP32 WROVER with 4Mb PSRAM / 16 Mb Flash
* SD/MicroSD reader
* HCM5883L Magnetometer
* BME280 Temperature / Humidity sensor
* MPU6050 Accelerometer and Gyroscope IMU
* HT1818Z3G5L GPS Module (AT6558D)
**Highly recommended an ESP32 with PSRAM**

> [!IMPORTANT]
> Please review the platformio.ini file to choose the appropriate environment as well as the different build flags for your correct setup.

### Makerfabs ESP32-S3 setup
### Boards

* ESP32-S3-WROOM-1 with 2Mb PSRAM / 16 Mb Flash
* MicroSD reader
* FT6236 Capactive Touch Panel Driver
* HT1612Z3M3L GPS Module (AT6558D)
* MPU9250 (Compass+IMU)
| | FLASH | PSRAM | Environment |
|:-----------------|:-----:|:-----:|:-----------------------------|
| ESP32 | 16M | 4M | ``` [env:ESP32_N16R4] ``` |
| ESP32S3 | 16M | 8M | ``` [env:ESP32S3_N16R8] ``` |
| MAKERFAB ESP32S3 | 16M | 2M | ``` [env:MAKERF_ESP32S3] ``` |

### Screens

| Driver [^1] | Resolution | SPI | 8bit | 16bit | Touch | Build Flags [^2] |
|:-----------:|:----------:|:---:|:----:|:-----:|:---------:|:--------------------------------:|
|:------------|:----------:|:---:|:----:|:-----:|:---------:|:---------------------------------|
| ILI9488 | 320x480 | yes | --- | --- | XPT2046 | ```-D ILI9488_XPT2046_SPI = 1``` |
| ILI9488 | 320x480 | --- | --- | yes | FT5x06 | ```-D ILI9488_FT5x06_16B = 1``` |
| ILI9341 | 320x240 | yes | --- | --- | XPT2046 | ```-D ILI9341_XPT2046_SPI = 1``` |

[^1]: See hal.hpp for pinouts configuration
[^2]: In the platformio.ini file under the build_flags section
### Modules

| | Type | Build Flags [^2] | lib_deps [^3] (**no common environment**) |
|:------------|:--------------|:---------------------------------|:-------------------------------------------------------|
| AT6558D | GPS | ```-D AT6558D_GPS = 1``` | |
| HMC5883L | Compass | ```-D HMC5883L = 1``` | ```adafruit/Adafruit Unified Sensor@^1.1.14``` <br> ```adafruit/Adafruit BusIO@^1.16.1``` <br> ```adafruit/Adafruit HMC5883 Unified@^1.2.3```|
| MPU9250 | IMU (Compass) | ```-D MPU9250 = 1 ``` | ```bolderflight/Bolder Flight Systems MPU9250@^1.0.2```|
| BME280 | Temp/Pres/Hum | ```-D BME280 = 1``` | ```adafruit/Adafruit Unified Sensor@^1.1.14``` <br> ```adafruit/Adafruit BusIO@^1.16.1``` <br> ```adafruit/Adafruit BME280 Library@^2.2.4```|


[^1]: See **hal.hpp** for pinouts configuration
[^2]: **platformio.ini** file under the build_flags section
[^3]: You need to add libraries dependencies if the buid flag requires

Other setups like another sensors, etc... not listed in the specs, now **They are not included**
Other setups like another sensors types, etc... not listed in the specs, now **They are not included**

If you wish to add any other type of sensor, module, etc., you can create a PR without any problem, and we will try to implement it. Thank you!

---

## Wiring

Pinout (ESP32-WROVER)
HCM5883L BME280 MPU6050 ILI9488 SD CARD VBAT GPS
-----------------------------------------------------------------------------------------------------
VCC 3,3v VCC 5v VCC 3.3v VCC 3,3v VCC 3,3v GPIO34 VCC 3,3v
GND GND GND GND GND GND GND GND GND GND ADC1_CHANNEL_6 GND GND
SDA GPIO21 SDA GPIO21 SDA GPIO21 LED GPIO33 CS GPIO4 (Resist. div) RX GPIO25
SCL GPIO22 SCL GPIO22 SCL GPIO22 MISO GPIO27 MISO GPIO19 TX GPIO26
SCK GPIO14 SCK GPIO12
MOSI GPIO13 MOSI GPIO23
DC GPIO15
RST GPIO32
CS GPIO2
LED GPIO33
TCS GPIO18
TIRQ GPIO5

Pinout (ESP32S3-MakerFabs)
GPS (HT1612Z3M3L) MPU9250
-----------------------------------------------------------------------------------------------------
VCC 3,3v VCC 3.3v
GND GND GND GND
TX GPIO17 SDA GPIO38
RX GPIO18 SCL GPIO39
See **hal.hpp** for pinouts configuration

## SD Map Tile File structure

Expand Down Expand Up @@ -171,33 +156,9 @@ Please follow the instructions provided by [OSM_Extract](https://github.com/ares
> pio run --target upload
> ```


> [!NOTE]
> For production version don't forget unset these environment variables.

If the GPS module supports multiple GNSS, uncomment the following flag in the platformio.ini file under the build_flags section

```bash
-D MULTI_GNSS=1
```

Depending on the IMU used, it will be necessary to indicate the following flags in the platformio.ini file.

First enable the compass
```bash
-D ENABLE_COMPASS=1
```

IMU HMC5883L
```bash
-D IMU_HMC5883L=1
```

IMU MPU9250
```bash
-D IMU_MPU9250=1
```

### TO DO

- [X] LVGL 9 Integration
Expand Down
3,022 changes: 1,505 additions & 1,517 deletions compile_commands.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/bme/bme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "bme.hpp"

#ifdef ENABLE_BME
#ifdef BME280

Adafruit_BME280 bme = Adafruit_BME280();

Expand Down
4 changes: 3 additions & 1 deletion lib/bme/bme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#ifndef BME_HPP
#define BME_HPP

#ifdef ENABLE_BME
#ifdef BME280

#define ENABLE_TEMP

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Expand Down
13 changes: 6 additions & 7 deletions lib/compass/compass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

int mapHeading = 0;

#ifdef ENABLE_COMPASS

#ifdef IMU_HMC5883L
#ifdef HMC5883L
Adafruit_HMC5883_Unified compass = Adafruit_HMC5883_Unified(12345);
#endif

Expand Down Expand Up @@ -46,12 +44,13 @@ int heading = 0;
float offX = 0.0, offY = 0.0;

/**
* @brief Init Compass
:wa
* @brief Init Compass
*
*/
void initCompass()
{
#ifdef IMU_HMC5883L
#ifdef HMC5883L
if (!compass.begin())
compass.begin();
#endif
Expand All @@ -75,7 +74,7 @@ void initCompass()
*/
void readCompass(float &x, float &y, float &z)
{
#ifdef IMU_HMC5883L
#ifdef HMC5883L
sensors_event_t event;
compass.getEvent(&event);
y = event.magnetic.y;
Expand Down Expand Up @@ -199,4 +198,4 @@ void compassCalibrate()
saveCompassCal(offX,offY);
}

#endif

8 changes: 4 additions & 4 deletions lib/compass/compass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

extern int mapHeading;

#ifdef ENABLE_COMPASS

#ifdef IMU_HMC5883L
#ifdef HMC5883L
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>
extern Adafruit_HMC5883_Unified compass;
#define ENABLE_COMPASS
#endif

#ifdef IMU_MPU9250
#include <MPU9250.h>
extern MPU9250 IMU;
#define ENABLE_COMPASS
#endif

#define COMPASS_CAL_TIME 16000
Expand All @@ -44,4 +44,4 @@ void compassCalibrate();

#endif

#endif

6 changes: 3 additions & 3 deletions lib/gps/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool isTimeFixed = false;
HardwareSerial *gps = &Serial2;
TinyGPSPlus GPS = TinyGPSPlus();

#ifdef MULTI_GNSS
#ifdef AT6558D_GPS

// DOP and fix mode
TinyGPSCustom pdop(GPS, PSTR("GNGSA"), 15); // $GNGSA sentence, 15th element
Expand Down Expand Up @@ -72,7 +72,7 @@ void initGPS()
GPS_GSV.msgNum.begin(GPS, PSTR("GPGSV"), 2);
GPS_GSV.satsInView.begin(GPS, PSTR("GPGSV"), 3);

#ifdef MULTI_GNSS
#ifdef AT6558D_GPS

GL_GSV.totalMsg.begin(GPS, PSTR("GLGSV"), 1);
GL_GSV.msgNum.begin(GPS, PSTR("GLGSV"), 2);
Expand All @@ -91,7 +91,7 @@ void initGPS()
GPS_GSV.azim[i].begin(GPS, PSTR("GPGSV"), 6 + (4 * i)); // offsets 6, 10, 14, 18
GPS_GSV.snr[i].begin(GPS, PSTR("GPGSV"), 7 + (4 * i)); // offsets 7, 11, 15, 19

#ifdef MULTI_GNSS
#ifdef AT6558D_GPS

GL_GSV.satNum[i].begin(GPS, PSTR("GLGSV"), 4 + (4 * i)); // offsets 4, 8, 12, 16
GL_GSV.elev[i].begin(GPS, PSTR("GLGSV"), 5 + (4 * i)); // offsets 5, 9, 13, 17
Expand Down
2 changes: 1 addition & 1 deletion lib/gps/gps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct GSV
* @brief Custom NMEA sentences
*
*/
#ifdef MULTI_GNSS
#ifdef AT6558D_GPS

// DOP and fix mode
extern TinyGPSCustom pdop; // $GNGSA sentence, 15th element
Expand Down
30 changes: 15 additions & 15 deletions lib/gui/src/mainScr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,21 @@ void updateSatTrack(lv_event_t *event)
if (GPS.altitude.isUpdated())
lv_label_set_text_fmt(altLabel, "ALT:\n%4dm.", (int)GPS.altitude.meters());

#ifdef MULTI_GNSS
switch ((int)activeGnss)
{
case 0:
fillSatInView(GPS_GSV, TFT_GREEN);
break;
case 1:
fillSatInView(GL_GSV, TFT_BLUE);
break;
case 2:
fillSatInView(BD_GSV, TFT_RED);
break;
}
#ifdef AT6558D_GPS
switch ((int)activeGnss)
{
case 0:
fillSatInView(GPS_GSV, TFT_GREEN);
break;
case 1:
fillSatInView(GL_GSV, TFT_BLUE);
break;
case 2:
fillSatInView(BD_GSV, TFT_RED);
break;
}
#else
fillSatInView(GPS_GSV, TFT_GREEN);
fillSatInView(GPS_GSV, TFT_GREEN);
#endif
}

Expand Down Expand Up @@ -574,7 +574,7 @@ void createMainScr()

#ifdef LARGE_SCREEN

#ifdef MULTI_GNSS
#ifdef AT6558D_GPS
lv_style_init(&styleRadio);
lv_style_set_radius(&styleRadio, LV_RADIUS_CIRCLE);

Expand Down
8 changes: 4 additions & 4 deletions lib/gui/src/notifyBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void updateNotifyBar(lv_event_t *event)

if (obj == gpsTime)
lv_label_set_text_fmt(obj, timeFormat, hour(now()), minute(now()), second(now()));
#ifdef ENABLE_BME
#ifdef ENABLE_TEMP
if (obj == temp)
lv_label_set_text_fmt(obj, "%02d\xC2\xB0", tempValue);
#endif
Expand Down Expand Up @@ -93,7 +93,7 @@ void updateNotifyBarTimer(lv_timer_t *t)
lv_obj_send_event(gpsFixMode, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_send_event(wifi, LV_EVENT_VALUE_CHANGED, NULL);

if (GPS.location.isValid())
if (GPS.location.isUpdated())
{
switch (GPS.location.FixQuality())
{
Expand All @@ -114,7 +114,7 @@ void updateNotifyBarTimer(lv_timer_t *t)
else
lv_led_off(gpsFix);

#ifdef ENABLE_BME
#ifdef ENABLE_TEMP
tempValue = (uint8_t)(bme.readTemperature());
if (tempValue != tempOld)
{
Expand Down Expand Up @@ -170,7 +170,7 @@ void createNotifyBar()
lv_label_set_text_static(wifi, " ");
lv_obj_add_event_cb(wifi, updateNotifyBar, LV_EVENT_VALUE_CHANGED, NULL);

#ifdef ENABLE_BME
#ifdef ENABLE_TEMP
temp = lv_label_create(notifyBarIcons);
lv_label_set_text_static(temp, "--\xC2\xB0");
lv_obj_add_event_cb(temp, updateNotifyBar, LV_EVENT_VALUE_CHANGED, NULL);
Expand Down
File renamed without changes.
18 changes: 8 additions & 10 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

[platformio]
description = ESP32 GPS Navigator
default_envs = CUSTOMBOARD
default_envs = ESP32_N16R4

[common]
platform = espressif32
framework = arduino
version = 0.1.8_dev
revision = 63
revision = 64
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0
Expand All @@ -27,8 +27,6 @@ build_flags =
-D CORE_DEBUG_LEVEL=5
-D USE_LINE_BUFFER=1
-D DISABLE_RADIO=1
-D AT6558D_GPS=1
-D MULTI_GNSS=1
-D BAUDRATE=115200
-D DEBUG=1
-D SHELLMINATOR_BUFF_LEN=70
Expand All @@ -52,10 +50,9 @@ lib_deps =
[esp32_common]
extends = common

[env:CUSTOMBOARD]
[env:ESP32_N16R4]
extends = esp32_common
board = esp-wrover-kit
upload_port = /dev/ttyUSB0
board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
lib_deps =
Expand All @@ -69,9 +66,9 @@ build_flags =
-DBOARD_HAS_PSRAM
-DARDUINO_ESP32_DEV
-mfix-esp32-psram-cache-issue
-D ENABLE_COMPASS=1
-D IMU_HMC5883L=1
-D ENABLE_BME=1
-D AT6558D_GPS=1
-D HMC5883L=1
-D BME280=1
-D ILI9488_XPT2046_SPI=1
-D TFT_BL=33

Expand All @@ -86,7 +83,8 @@ lib_deps =
build_flags =
${common.build_flags}
-DBOARD_HAS_PSRAM
-D ENABLE_COMPASS=1
-DARDUINO_ESP32S3_DEV
-D AT6558D_GPS=1
-D IMU_MPU9250=1
-D ILI9488_FT5x06_16B=1
-D TFT_BL=45
Expand Down
Loading
Loading